Support » Plugin: Dynamic Image Resizer » solution: filenames without "c"

  • Plugin works great but we didn’t want to change the filename convention by adding a “c” for cropped images.

    The solution:
    1) Remove the “c” from filenames
    (lines 32 and 82 remove: if ($size['crop']) $suffix .='c';)
    2) Set crop to true
    (line 22: $crop = true;)

    The joke: In WP metadata the accurate width x height is already calculated for each image format, so when you autogenerate the image later on it doesn’t matter if you crop. if you crop a non-crop image you’ll simply crop nothing …

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Samuel Wood (Otto)


    If you remove the c in the filename, then hard cropped images (third parameter of add_image_size set to true) will no longer work. And if you don’t use hard cropped image sizes, then the c won’t be used anyway. So this change would be rather pointless.

    We use both hard cropped image sizes and flexible ones:

    add_image_size( 'thumbnail', 190, 190, true );
      add_image_size( 'medium', 221, 9999, false );
      add_image_size( 'large', 640, 360, true );
      add_image_size('huge', 950, 490, true);
      add_image_size('teaser-S', 90, 90, true);
      add_image_size('teaser-M', 160, 160, true);
      add_image_size('teaser-XL', 460, 330, true);
      add_image_size( 'largetrue', 460, 9999, false );
      add_image_size( 'mr-full', 600, 9999, false );

    It works perfectly fine without the “c” and $crop set to true – just try it.
    The point is: Just crop every image even when it’s not necessary, it doesn’t matter – you will always get the same result.

    Plugin Author Samuel Wood (Otto)


    I don’t think you understand what the hard cropping does. It does not give the same results as not cropping.

    If I upload an image that is 100×200, and I have add_image_size(50,100,XXX), then yes, it doesn’t matter whether XXX is true or false. The image size and the actual image are proportional to one another already, so you will indeed get the same result.

    But if I upload an image that is 100×200 and I have add_image_size(50,50,XXX), then I will get different results for true and false. A value of true will hard crop and give me back a 50×50 image. A value of false will proportionally scale and give me back a 25×50 image.

    Hard cropping does what it says on the box, it hard crops the image to the center. If you don’t use hard cropping, you get proportional scaling.

    Plugin Author Samuel Wood (Otto)


    The reason your examples don’t see this, BTW, is because you are using 9999 for all the non-hard-cropping images in your example list above. You’re only proportionally scaling to one parameter, making the hard crop irrelevant. Anybody else using this in the way it was intended won’t have your specific needs there.

    ok, to use your sample:

    upload: 100×200

    case 1: add_image_size(50,50,true) -> stores meta: imagename-50×50.jpg

    case 2: add_image_size(50,50,false) -> stores meta: imagename-25×50.jpg

    now resize both with your function on the fly with $crop=true; and you will get the pics you want … so no “c” needed

    Plugin Author Samuel Wood (Otto)


    If you resize with crop=true, then you won’t get the sizes you want unless you define the sizes in specific manners.

    Your case two is incorrect, basically, because right there you have $crop set to false, not true.

    Cropping and non-cropping are separate things. I can have a 50×50 image which was cropped because it was rectangular, and another 50×50 image which was not cropped because it was square, but I need to refer to them in a consistent manner. Eliminating the c eliminates the distinguishing factor and produces inconsistency among different sized images while having a standard set of resizers.

    All you’ve done is to set it to always hard-crop, and then to define your image sizes in a manner where they are always proportional to the images you’ve uploaded. This won’t work universally, and the crop flag needs to be properly passed to the resizer code, via the filename.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘solution: filenames without "c"’ is closed to new replies.