• Resolved kurtrank

    (@kurtrank)


    I have discovered that images larger than 2560px cause a mismatch with image metadata stored in the database. This causes an issue when using another plugin (Crop-Thumbnails) that allows for precise crop framing. In the image below, you can see on the left the final crop output, which does not match my crop selection in the left side. I believe this is because WordPress still has the image dimensions saved as 2560x1707 (also visible in the screenshot) but in reality the scaled image file has been removed and the full 5367x3578 image is used instead.

    I double-checked the image meta in the database to confirm:

    Array
    (
    
        // this is the width of the scaled file, the original is actually 5367
        [width] => 2560
        [height] => 1707
    
         // -scaled is missing from the filename
        [file] => 2023/03/pexels-andrey-grushnikov-940034.jpg
        [filesize] => 890443 // this filesize is also for the scaled version
        [sizes] => Array
            (
                [medium] => Array
                    (
                        [file] => pexels-andrey-grushnikov-940034-300x200.jpg
                        [width] => 300
                        [height] => 200
                        [mime-type] => image/jpeg
                        [filesize] => 18065
                    )
                // other sizes...
            )
    )

    Here are details on my local environment used to troubleshoot this if it helps:

    Reviewing the changelog for this plugin I found a note about the scaled size:

    6.2.0 – Tested up to 5.8.2, placeholder fallback, change filter priority to apply earlier the available sizes, fix warnings for info not available in some of the core versions, fix warnings for estimated sizes missing width or height, attempt to bypass scaled size naming, updated sizes filter for backward compatibility, logs length limit, log the WP-CLI command executions, styles adjustments

    This is only an issue when images larger than 2650 are uploaded (which is when WP tries to make a ‘scaled’ version) so most of the time it is not a big deal, but there is a chance some editors on the sites I maintain may upload larger sizes without realizing. Is it possible to bypass this removal of ‘scaled’? I did not see a hook or setting in the admin that was related here, but might be nice. In my case I would like to keep the default WordPress functionality and the ‘scaled’ size it creates, along with everything else your great plugin does.

    Otherwise, I think the metadata for the image should stay in sync if the ‘scaled’ version is removed. I think this change would also fix the problem I am having when trying to do a custom crop through this Crop-Thumbnails plugin even if I cannot use the ‘scaled’ size with your plugin.

    • This topic was modified 1 year, 8 months ago by kurtrank.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Iulia Cazan

    (@iulia-cazan)

    Hi,

    I think I understand what you need, and will attempt to replicate the behavior on my local and see if I can come up with a filter for this. Will let you know if I have updates. Thanks for letting me know about this scenario!

    Regards,
    Iulia

    Plugin Author Iulia Cazan

    (@iulia-cazan)

    Hi,

    Please upgrade to 7.1.0. There is a new filter you can use, sirsc_keep_scaled. You can add to your project something like this:

    \add_filter( 'sirsc_keep_scaled', '__return_true', 10 );
    Let me know how it goes.

    Regards,
    Iulia

    Thread Starter kurtrank

    (@kurtrank)

    Thanks so much for adding that filter! It works great! Your plugin is really helpful, this was the only problem I came across so I really appreciate it ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Image metadata incorrect when larger than 2650, causing crop issues’ is closed to new replies.