zachary.lv
Forum Replies Created
-
Forum: Plugins
In reply to: [WP SmartCrop] Plugin does not work with custom image sizes in themeTurns out I was right the first time. There is an issue with this plugin working with themes and plugins that define custom image sizes. It also prevents the plugin from working when templates make a call for images with the post-thumbnail size defined by WordPress.
The normal procedure for adding custom images sizes and setting a custom post thumbnail size use add_image_size() which registers the custom size in the $_wp_additional_image_sizes global variable. However, although the WP SmartCrop loads this variable when it checks for available image sizes, it does not use the values stored in this variable to confirm if an image should output the wpsmartcrop classes and data attribute.
Instead the plugin pulls the dimensions and crop value for registered image sizes from the options table in the database on lines 598-602 in wp-smartcrop.php. These options only exist for the default image sizes in WordPress (thumbnail, medium, medium-large, large). Because of this SmartCrop will not work for any custom image sizes, or for the post-thumbnail size defined in WordPress, as that also does not record dimensions in the database.
I was able to solve this problem on my custom theme by calling update_option( $my_size . ‘_size_w’, $width ); etc for all my custom defined image sizes after adding them with add_image_size() and for the post-thumbnail size. This makes the option data available when SmartCrop tries to verify an image size will support a focus point. This data is irrelevant to WordPress core and my custom theme, however, so it’s just a bandaid in a sense.
The plugin should be updated so it can work properly with custom image sizes.
A bit of a headache sorting this out, but otherwise a cool plugin when it’s working.
Forum: Plugins
In reply to: [WP SmartCrop] Plugin does not work with custom image sizes in themeI was doing some additional testing with one of WordPress’ default themes and realized that it’s not custom image sizes that prevent the plugin data from being output, it’s inserting images from an image that uses a hard-crop that prevents output of the data.
I take it this is on the assumption that images with a hard crop don’t account for extra space necessary to adjust the focal point.