You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 );
}
The text was updated successfully, but these errors were encountered:
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.
It can very well be that what you found is causing that behavior. I didn’t see that behavior myself, but I will investigate and see if there’s something I can do about it.
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.
This is true, but the check for the query-attachments was mainly added for performance reasons. When you open a Media view to select an image and Timmy has to generate sizes for each and every image in the view, you can run into serious performance problems. It could mean waiting more than a minute until you can select the image you’re looking for.
But I see that this is probably mainly an issue while developing a site, where image sizes might change more frequently. I’m sure I can find a solution for this. Maybe I can catch the preview error, or maybe I’ll introduce a filter to disable this.
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
The text was updated successfully, but these errors were encountered: