WordPress.org

Ready to get started?Download WordPress

Forums

Thumbnails.. (4 posts)

  1. iperez_genius
    Member
    Posted 1 year ago #

    When i upload and image to the media manager are all the image sizes set in the media tab under setting created as well?

    at the moment i have an image in a post and i need that same image to be a thumbnail. I am using css and html to resize the image however if the image is huge the resize is okay but effectively the user will have to download the full image.

    I want to load a thumbnail instead.

    What is the best way to achieve this?

    Ilan

  2. Emphacy
    Member
    Posted 1 year ago #

    Yes WordPress automatically generates all image sizes from the image you upload, that includes the full size, large, medium, and thumbnail.

    You can select the size of the image you want to insert into the post using the media uploader.

    Alternatively:

    The thumbnails are the names of the original image with the image size appended to the end, typically thumbnails are 125x125px.

    Hence if you upload an image called hello.jpg and find the URL for that file, typically:

    http://yourwebsite/wp-content/uploads/2012/10/hello.jpg

    The thumbnail will therefore be:

    http://yourwebsite/wp-content/upload/2012/10/hello-125x125.jpg

  3. iperez_genius
    Member
    Posted 1 year ago #

    how do i access this through code?

  4. lucentx
    Member
    Posted 1 year ago #

    You could do something like this inside the loop:

    <?php
      $size = 'thumbnail'; //thumbnail, medium, large or full
      echo get_the_post_thumbnail(get_the_ID(), $size, '');
    ?>

    Or if you want to create a custom size you can do something like this:

    <?php
    if ( function_exists( 'add_image_size' ) ) {
      add_image_size( 'homepage-thumb', 220, 130, true );
    }
    echo get_the_post_thumbnail(get_the_ID(), 'homepage-thumb', $attr);
    ?>

    More info here

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags