WordPress.org

Ready to get started?Download WordPress

Forums

add_new_image Hard Crop Not Working (10 posts)

  1. DeltaHF
    Member
    Posted 4 years ago #

    I added the following to functions.php:

    add_theme_support( 'post-thumbnails' );  // for posts only, not pages
    set_post_thumbnail_size( 200, 200, true );	//200x200, hard-crop mode enabled
    add_image_size( 'tiny-thumb', 75, 75, true ); //sidbar thumbs, 50x50, no hard-crop

    And then I want to reference the "tiny-thumb" image in a loop located in sidebar.php, which I'm referencing like so:

    the_post_thumbnail('tiny-thumb');

    Unfortunately, that outputs the following (actually, the image's largest dimension, height or width, is set to 75, and the other value is relative to keep the aspect ratio):

    <img width="75" height="75" title="my-image-title" alt="" class="attachment-tiny-thumb wp-post-image" src="http://example.com/path-to-original-image">

    The problem is that the original image is shown, not the new hard-cropped 75x75 thumbnail that I want. Yes, I have rebuilt all thumbnails using the "Regenerate Thumbnails" plugin, and I have manually uploaded new files after making these changes without any luck. Additionally, I can change the dimensions in functions.php's add_image_size() and the image's height and width will change, but it's still just the original image and is not being hard-cropped. What can I do?

  2. DeltaHF
    Member
    Posted 4 years ago #

    A gentle bump...

  3. stunnaboi
    Member
    Posted 4 years ago #

    Some say I'm a dreamer, but I'm not the only one! Having the same exact issue. What version are you running? I'm testing 3.0Beta1.

  4. DeltaHF
    Member
    Posted 4 years ago #

    Hm, I'm on 2.9.2. Not good to hear that it's also happening on 3.0. :(

  5. stylishbeachbum
    Member
    Posted 4 years ago #

    I'm using WordPress 2.9.2 and I'm trying to create a photo gallery with hard cropped images. I've got basically the same code as DeltaHF, except different sizes and different name for my custom size. I display the image with:

    <?php echo wp_get_attachment_image($attachment_id, $size = 'gallery', $icon = false ); ?>

    And I get a cropped image, but it is not hard cropped - the aspect ratio is maintained. It's a nightmare to work with. Everytime I test I delete the images and load new ones.

    Anyone got any ideas why this might be? I'm working on a Mac and wondered if this might be a platform specific problem. Anyone had this problem and found a solution?

  6. stylishbeachbum
    Member
    Posted 4 years ago #

    I moved my wp site from my macbook to an Ubuntu server. As soon as I did that wp hard cropping started working. My guess is that the hard cropping needs a library or program such as Image Magic to do the re-sizing and that it isn't present on some platforms.

  7. Charles Kelley
    Member
    Posted 4 years ago #

    It's not the platform.

    This worked like a charm for me. The problem lies in you putting images as thumbnails that were already uploaded before you specified the image size you wanted. Any new images you upload and set should work like a charm. As for the old one, try this plugin that regenerates all your thumbnails:

    http://wordpress.org/extend/plugins/regenerate-thumbnails/

  8. kath
    Member
    Posted 4 years ago #

    Hum.

    For me, the cropping is working, and some of my images are regenerating when I Regenerate Thumbnails, but others aren't. So WordPress will use the newly created thumbnail with my special sizing and correct cropping for some images, and not for others. All of the images were uploaded prior to the creation of the new image sizes. But it looks like any images uploaded before 2009 didn't get regenerated. I deleted and re-installed Regenerate Thumbnails and no luck, so I'm just replacing the images.

  9. Alex Mansfield
    Member
    Posted 3 years ago #

    @stylishbeachbum I think you are correct about the hard crop depending on a library. I believe it needs the php-gd library. Installing it will not crop images that were already uploaded though. You will need to either manually upload the images again, or use the Regenerate Thumbnails plugin.

  10. edwinvaldez
    Member
    Posted 3 years ago #

    Hi guys.

    I´ve spent a lot of my day looking for a solution for this issue and here is the solution, in front of my eyes! Thanks to stylishbeachbum and Alex Mansfield. Yeah, the issue depends of the server. I´m using apache/php/mysql on Windows XP and the php_hd2 extension wasn´t enabled.

    I´ve enabled that and now is working.

    Thank you guys.

Topic Closed

This topic has been closed to new replies.

About this Topic