Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non Image Attachments Throw Notices #42

Open
christianmagill opened this issue Sep 12, 2021 · 1 comment
Open

Non Image Attachments Throw Notices #42

christianmagill opened this issue Sep 12, 2021 · 1 comment

Comments

@christianmagill
Copy link

If you have an attachment that is not an image in your media library, then wp_get_attachment_image_src will return false and thus not have an array offset.

'Notice: Trying to access array offset on value of type bool in /Users/christianmagill/Code/Sites/extended/wp-content/plugins/jarvis/src/php/models/post.php on line 21'

@christianmagill
Copy link
Author

christianmagill commented Sep 12, 2021

You can make use of https://developer.wordpress.org/reference/functions/wp_attachment_is_image/ to qualify the conditional.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant