Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When images are uploaded in the same size as set in 'preview' it can be that image_display calls _image_build_derivatives while this is not needed.
I have a situation here $node->images['_original'] contains the same path as $node->images['preview']
now image_display checks the path, that's OK
next it checks filemtime(file_create_path($node->images[$label])) < variable_get('image_updated', 0))
and this always returns true and it tries to recreate the images, but it won't recreate the preview as it's the same sie as _original.....
my files table does not contain an entry for 'preview'....
Comments
Comment #1
bwynants CreditAttribution: bwynants commentedactualy this is because preview was set at 550,550 and image was 550,433
_image_build_derivatives inserts the '_original' for these images
Comment #2
jsloan CreditAttribution: jsloan commentedI posted this issue here // regenerate images?
Comment #3
bwynants CreditAttribution: bwynants commentedjeah, same issue.
here's how I fix this until there is an 'official' patch is available...
Comment #4
bwynants CreditAttribution: bwynants commentedbad fix, don't do it like that. Loading a node can put '_original' path in as well, causing it to never recreate the needed images...
Comment #5
bwynants CreditAttribution: bwynants commentedjsloan: I understand your problem and you are also right but it's definitely another issue...
What is my problem? It's even worse as yours :-).
eg. you put preview size at 640x480 in image settings
you upload an image of 550x400
now EVERY time someone watches the image the thumbnail is regenerated (as are other defined formats)!
Why?
At the moment the image is viewed you always view the original, there is no preview image created by _image_build_derivatives since the 'original' image is already smaller as the needed 'preview' image size. Image_display does a chack and always compares the date of the original image with the last time the image settings where changed.... it triggers _image_build_derivatives but _image_build_derivatives does not recreate the 'preview' image meaning the 'original' date is never changed and the preview image date is also not changed. However the thumbnail is recreated! Next time someone watches the image, same thing happens.....
I see 2 solutions
1) when _image_build_derivatives also 'touch' the original file...
2) remember or an image when the last call to _image_build_derivatives was made via an extra property ($node->image_derivatives_created ) when comparing if the settings changed date is newer do not compare it with the 'file creation date' but with the $node->image_derivatives_created property...
any other ideas?
Comment #6
walkah CreditAttribution: walkah commentedthe big issue here is when the image file is the same as the _original (i.e. it doesn't get updated on build_derivatives)... I've added a check to avoid this.
please update to the latest version. thanks :)
Comment #7
bwynants CreditAttribution: bwynants commenteddid that, thanks, but what about my comment 4? if I change the settings and lower a size in the table that whas previous above or equal to original size that image is not recreated because it initially points to 'original' when loading the node...
Comment #8
drewish CreditAttribution: drewish commentedThis version is no longer supported. If this issue is occurring with a more recent version please open a new issue.