WordPress.org

Ready to get started?Download WordPress

Forums

image size in the_content (5 posts)

  1. leegee
    Member
    Posted 3 years ago #

    Is it possible to specify the size of the image rendered by the_content?

  2. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    you do this when yo insert the image into the text of your post/page.

    you can edit the image, and use the advanced option to set the image size exact to the pixel

  3. leegee
    Member
    Posted 3 years ago #

    Sorry I wasn't clear.

    I have a category whose posts consist of a single, captioned image.

    index.php currently renders each image in a different size container, with attributes to allow CSS to change the apparent size.

    But still lots of large images are downloaded.

    I would like to be able to specify what size of image is to be downloaded - thumbnail, medium, original.

    Is that possible? Will I need to subclass the_content() ?

    Thanks
    Lee

  4. joff
    Member
    Posted 2 years ago #

    hi leegee

    i've the same problem, how did you managed?

    thanks

  5. Chip Bennett
    Theme Review Admin
    Posted 2 years ago #

    Just customize the loop for that particular category. e.g.

    Here's the normal loop:

    <?php
    if ( have_posts() ) : while ( have_posts() ) : the_post();
        // NORMAL LOOP OUTPUT GOES HERE
    endwhile; endif;

    You're going to replace // NORMAL LOOP OUTPUT GOES HERE with something like this:

    if ( in_category( $id ) ) {
         $attachment_images = get_posts( array(
             'post_type' => 'attachment',
             'numberposts' => 1,
             'post_parent' => $post->ID
         ) );
         $attachment_image = $attachment_images[0];
         wp_get_attachment_image( $attachment_image->ID, 'large' );
    } else {
        // NORMAL LOOP OUTPUT GOES HERE
    }
     ?>

Topic Closed

This topic has been closed to new replies.

About this Topic