Hi,
actually I stumbled over the same mistake but why is it necessary to check for an object?
If it is a object it should also work without the check but it doesn’t? @texnixe please can you explain it to me why the check is necessary?
If you store an image in a files field and then try to convert the value that is stored in the content to a file object, this will return null if the image was removed/renamed in the meantime.
However, you can only call a file class method like crop()on an object of that class (not on null, a string, an object of another class etc.)
In PHP 8 we will be able to use the nullsafe operator shortcut instead of the if condition: