Plugin does not work with custom image sizes in theme
-
I was testing using this plugin with a custom theme, but could not get the img output to include the wpsmartcrop* classes, or data-smart-crop-focus attributes.
I dug into the plugin code and added some error logging to monitor what data was being passed around when the_content filter added by the plugin executes.
From what I’ve seen it appears the plugin won’t work with themes that define custom sizes. WP_Smart_Crop->is_image_size_cropped() returns true if WP_Smart_Crop->get_image_sizes() finds additional images sizes registered in WordPress. When this occurs WP_Smart_Crop->get_smartcrop_focus_attr() returns no data, which means WP_Smart_Crop->make_new_content_img_tag() returns the original img tag unaltered.
I edited the function WP_Smart_Crop->is_image_size_cropped() to always return false, and then the plugin started working, and I was seeing the focus point data behave as expected. Is there a reason the WP_Smart_Crop->is_image_size_cropped() function exists, and is there some way it can be fixed so this will work with themes that define custom image sizes?
- The topic ‘Plugin does not work with custom image sizes in theme’ is closed to new replies.