Wordpress Jetpack Tiled Gallery loading full size images then resizing them down to thumbnails

944 views Asked by At

I am using a Jetpack Tiled gallery as a widget for my site. It was taking forever to load.

I realized that the thumbnails were actually loading the full size images and then sizing them down to small thumbnails. The originals are very large, so that is why it was taking so long.

I noticed that in all of the jetpack gallery examples online the source of the image looked like this:

http://example.com/wp-content/uploads/2013/10/test.jpg?w=83&h=110

When I go to the URL for those examples, the image is resized correctly. However, those parameters do not work on my site and the full size image is loaded instead.

Is there any way to solve this?

1

There are 1 answers

0
Niclas On

I noticed this behaviour today as well, took some heavy galleries to notice that it was actually serving my high res images for the gallery. I made a quick fix that uses the different image versions that are available.

It's a quick'n'dirty fix, it should really check all registered image sized with get_intermediate_image_sizes() and sort on sizes and return the proper URL. Well well...This fix will save me bandwidth and load times.. I patched the rectangular_talavera. in plugins/slimjetpack/modules/tiled-gallery/tiled-gallery.php

$size = 'large';
if ( $image->width <= 150 ) {
    $size = 'thumbnail';
} elseif ( $image->width <= 590 ) {
    $size = 'medium';
}

$image_title = $image->post_title;
//$orig_file = wp_get_attachment_url( $image->ID );

$image_attributes = wp_get_attachment_image_src( $image->ID, $size ); // returns an array
$orig_file= $image_attributes[0];