-
Notifications
You must be signed in to change notification settings - Fork 4
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
Errors when image field is not correctly formatted or empty #7
Comments
thank you for the inspection .... your PR will be appriciated .. |
Added check to see if image name is formatted correctly. Otherwise it'll skip this asset.
I installed the plugin into an existing project which already has some images set in the tables.
When I call
$image->thumbnail('image','small')
it throws an error ErrorException Undefined offset: 1 on line 197 of drh2so4\thumbnail\src\Traits\Thumbnail.php
this is to be expected of course because there's no check after the explode on "-" character if the length is actually higher than 1. So calling [1] on the split will fail.
I tried to prevent the error by using hasThumbnail but this is using the exact same function so not resolved.
When I clear the image column for that particular row, it also doesn't work when calling "hasThumbnail".
Again because there's no check if result of this search is null
Code:
I can get around it for now by checking the column value on the model.
Maybe if I have time I'll see if I can push a fix but not a lot of time at the moment.
UPDATE
Apparently the issue is because some file in my uploads didn;t follow the correct naming (older upload before adding the library). Still consider this a bug. Also wonder how performant this is but that's another discussion :-)
It's fixed when you add the following to drh2so4\thumbnail\src\Traits\Thumbnail.php (line 197)
The text was updated successfully, but these errors were encountered: