User Photo
Thumbnails Height (2 posts)

  1. xjavier
    Posted 4 years ago #

    This plug-in calculates the height of the thumbnail according to the original image's width and height.

    So you will get different heights from each userĀ“s photo

    This is the original code

    `// figure out the longest side

    if ( $info[0] > $info[1] ) {

    $image_width = $info[0];

    $image_height = $info[1];

    $image_new_width = $maxdimension;

    $image_ratio = $image_width / $image_new_width;

    $image_new_height = $image_height / $image_ratio;

    //width is > height

    } else {

    $image_width = $info[0];

    $image_height = $info[1];

    $image_new_height = $maxdimension;

    $image_ratio = $image_height / $image_new_height;

    $image_new_width = $image_width / $image_ratio

    //height > width


    $imageresized = imagecreatetruecolor( $image_new_width, $image_new_height);

    @ imagecopyresampled( $imageresized, $image, 0, 0, 0, 0, $image_new_width, $image_new_height, $info[0], $info[1] );

    What would be nice is to have a fixed height thumb with the image centered so the Image get cropped with criteria.

    Right now, i have different thumbs heights in a 120x80 box, i had to fix this by overriding its container div (overflow: hidden), so the image *is* 120*80 with no resizing, but then the image starts from the Top Left of the block, with nasty results about the position of the photo.

    In my particular case, i need the thumbs to fit in a 120px.80px box, and the image composition (imagine a tree, a car and a tree, right now i have a 120/80 box with a tree and half car) so it should be centered.

    any hint? thank you.


  2. Steve Taylor
    Posted 3 years ago #

    I've posted some code to modify this plugin to crop the thumbnails to a square:


    Obviously hacking a plugin isn't ideal, but I need this feature - and hopefully the code will make it into a future release. Meantime, hopefully it can help others needing the same feature.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • User Photo
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic