-
Notifications
You must be signed in to change notification settings - Fork 14
Description
I've created an ACF image field and set the preview image to a landscape size defined in the Timmy configuration.
When i click "select image" and select an image in the Media Library it seemed the wrong preview image size was returned, because the preview showed a thumbnail size. After saving the post and returning to the ACF field it worked perfectly and it showed the right size.
When inspecting the AJAX request upon selecting the image i saw that the src of the different media sizes were all set to the thumbnail size. Searching through the Timmy code i stumbled upon the part which caused this and it's a feature to prevent the system from unnecessarily creating many image sizes on the fly. For now i disabled that part of the code because i pre generate all the image sizes.
Does anyone encounter the same behaviour? is it something to get used to or can we somehow create a workaround? Because i really like the way this plugin enables me to deal with responsive images.
Installed using Composer
Timmy: 0.14.0
Timber: 1.9.4
Wordpress: 5.1.1
Timmy.php Line:291
/**
* Return thumbnail size when media files are requested through an AJAX call.
*
* When image data is prepared for the Media view, WordPress calls 'image_size_names_choose'
* to get all selectable sizes for the backend and then 'image_downsize' to get all the
* image data. All image sizes that don’t exist yet would be generated, which probably
* causes a max execution timeout error.
*
* We make sure that for the Media view, we only return the thumbnail size for an image. If
* the thumbnail size doesn’t exist yet, it is generated.
*
*
* @see wp_prepare_attachment_for_js()
* @since 0.12.0
*/
if ( 'query-attachments' === $action ) {
$thumbnail_size = Helper::get_thumbnail_size();
list( $width, $height ) = Helper::get_dimensions_for_size( $thumbnail_size );
$crop = Helper::get_crop_for_size( $thumbnail_size );
$force = Helper::get_force_for_size( $thumbnail_size );
// Resize to thumbnail size
$src = self::resize( $thumbnail_size, $file_src, $width, $height, $crop, $force );
//echo $src;
/**
* Get original dimensions for a file that are used for the image data and the select
* input when an image size can be chosen in the backend.
*
* The src is still the thumbnail size, so that it doesn’t trigger a resize.
*/
$original_size = Helper::get_image_size( $size );
list( $width, $height ) = Helper::get_dimensions_for_size( $original_size );
return array( $src, $width, $height, true );
}