WordPress.org

Ready to get started?Download WordPress

Forums

Uploaded image is being resized to the same size as full (11 posts)

  1. wilirius
    Member
    Posted 12 months ago #

    When I upload an image of say size 940x300 it is being resized by wordpress with the extension 940-300. This is completely unnecessary and also creates a worse image because the full size image IS already that size and optimized.

    I was pretty sure that WP did not create this redundancy, yet I am witnessing it in the most recent theme I am using.

    I am also using wp_get_attachment_image_src as it is the command which is searching for the image and returning the one with the extension.

  2. wilirius
    Member
    Posted 12 months ago #

    In other words, why is WP resizing to the size that it already is.

  3. esmi
    Forum Moderator
    Posted 12 months ago #

    What theme are you using? Where did you download it from?

  4. wilirius
    Member
    Posted 12 months ago #

    It is from thememonster, and edited a good bit.

    add_image_size( 'mySize', 940, 300, true );

    Note that hard-crop is set to true, but no crop should be necessary! And no resize should be necessary.

  5. esmi
    Forum Moderator
    Posted 12 months ago #

    Can you replicate the problem using the default Twenty Twelve theme with all plugins deactivated? I'm sorry but as you are using a non-WPORG theme, you need to seek support from the theme's developers - paid or otherwise. We only support themes downloaded from wordpress.org here.

  6. wilirius
    Member
    Posted 12 months ago #

    Yes, I can duplicate the problem with Twenty Twelve with all plugins deactivated.

    I added a custom image size :

    add_image_size( 'mySize', 940, 300, true );

    I added the image to a fullwidth page to test it:

    <?php
      $myImage = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'mySize');
      echo "<img src='";
      echo $myImage[0];
      echo "' alt=''/></a>";
    ?>

    I uploaded an image to test this with while Twenty Twelve was activated.

    The image was still resized/duplicated despite already being the correct size.

  7. esmi
    Forum Moderator
    Posted 12 months ago #

    I added a custom image size

    And that is where the issue is being created. By including that line you are specifically asking WordPress to create this new image. If you are uploading images of the correct size, why do you need add_image_size() at all?

  8. wilirius
    Member
    Posted 12 months ago #

    I tested it with a new upload and

    add_image_size( 'mySize', 940, 300);

    The issue still exists.

  9. wilirius
    Member
    Posted 12 months ago #

    Ah, ok. It is for future proofing. If someone else uploads an image in the future and uses a wrong size then I would prefer it to have been adjusted to the appropriate size via resizing.

  10. esmi
    Forum Moderator
    Posted 12 months ago #

    Then I'm afraid you're pretty much caught between a rock & a hard place. If you want to future proof image uploads, then you'll have to trade that off against the odd image being replicated. As far as I'm aware, there's nothing in WordPress core that can be easily used to determine the image size during the upload process and apply add_image_size() conditionally. Well, not unless you want to get into some pretty hefty custom coding.

  11. wilirius
    Member
    Posted 12 months ago #

    Thanks esmi! I could've sworn I had seen it done before, and I just assumed it was WP doing the work, so I'll go back and look around for it. But like you're saying it might have been some javascript to replace the img src or something else. Thanks again.

Reply

You must log in to post.

About this Topic