• Resolved VFHwebdev

    (@vfhwebdev)


    I have some thumbnail sizes that have almost identical aspect ratios.

    For example:
    thumb1: 407×250
    thumb2: 775×476

    These are the widths of images I need in my layout. And this is as close to the same aspect ratio as I can get.

    But Crop Thumbnails doesn’t recognize these as having the same aspect ratio. I’m guessing because while they are very very close, they are not identical.

    In order to make them identical, I’d have to make thumb2 775×476.0442.

    Is there any way to make Crop Thumbnails a little less strict on matching exact aspect ratios? Maybe make it round to the nearest pixel?

    Thanks!

    https://wordpress.org/plugins/crop-thumbnails/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Volkmar Kantor

    (@volkmar-kantor)

    hi,
    would it be sufficient if you had a wordpress-filter to adjust the ratio?

    Relevant code is in editor.php.
    On line 294 i provide the value. I could wrap the ratio-value inside a filter so you can adjust it as you want.

    I can not garantie that this will work smoothly when saving the image, but i assume it will.

    Thread Starter VFHwebdev

    (@vfhwebdev)

    I’m not sure I follow you. So would I essentially be hardcoding the ratio for each of my thumbnail sizes?

    Plugin Author Volkmar Kantor

    (@volkmar-kantor)

    No, it would not be hardcoded in the plugin. You will be able to add the code i.e. in the functions.php of your theme (once it is implemented).

    My question is: are you ok with that?

    Plugin Author Volkmar Kantor

    (@volkmar-kantor)

    Hi,
    with version 0.10.4 you can adjust the ratio-mapping on your needs.

    You have to add the following code (i.e. into your themes function.php).

    add_filter( 'crop_thumbnails_editor_printratio', 'my_crop_thumbnails_editor_printratio', 10, 2);
    function my_crop_thumbnails_editor_printratio( $printRatio, $imageSizeName) {
        if($imageSizeName === 'your-image-size-with-strange-ratio') {
            $printRatio = '4:3';//do override ratio
        }
        return $printRatio;
    }

    Thread Starter VFHwebdev

    (@vfhwebdev)

    Great! Yeah, I didn’t mean literally hardcoded in the plugin, but with the filter, I’m essentially telling Crop-Thumbnails what aspect ratio to use for each thumbnail. I think this will do what I need!

    Plugin Author Volkmar Kantor

    (@volkmar-kantor)

    It will … i checked 😉

    Thread Starter VFHwebdev

    (@vfhwebdev)

    This works perfectly! Thanks so much for the help.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Help with similar aspect ratios’ is closed to new replies.