• I am trying to get my thumbnails to respond to alignment settings, set in the “Add an Image” pop-up window.. When inserting an image into your post, if you choose to align it (left, center, right) it assigns the corresponding class to that image (alignleft, aligncenter, alignright). As far as I can tell, this doesn’t apply to image thumbnails. Has anyone been successful in getting this to work?

Viewing 11 replies - 1 through 11 (of 11 total)
  • You probably need to edit your theme’s stylesheet. Site url?

    Thread Starter colindunn

    (@colindunn)

    https://www.colindunn.com

    Its not a CSS issue. Aligning the thumbnail in edit mode isn’t assigning a class to the image, so there is no way to control that element specifically with css.

    Thread Starter colindunn

    (@colindunn)

    More specifically, if you go to https://www.colindunn.com/blog the image of the tv is set to align right

    Thread Starter colindunn

    (@colindunn)

    According to this article, this feature is yet to be implemented. Is there a method for requesting features in wordpress?

    Aligning the thumbnail in edit mode isn’t assigning a class to the image

    Tha’s because the image seems to have been set as the post thumbnail and isn’t being pulled by the_content() in the normal manner. For a start, on the single post page, it’s after the <!--more--> tag – not before it.

    And support for the_post_thumbnail was added in WP2.9

    so there is no way to control that element specifically with css.

    Try adding:
    .attachment-post-thumbnail {float:right}

    to the bottom of your your stylesheet which will align all of your post-thumbnails to the right.

    Thread Starter colindunn

    (@colindunn)

    Thanks for your help esmi. Right now I am using the the_post_thumbnail to get the thumbnail and the_content to get the content. Is this not the best way to do it? I am able to position them in any order I want this way.

    And if I added

    .attachment-post-thumbnail {float:right}

    That would float ALL of my thumbnail images to the right. I wanted to have the option of floating some to the left and some to the right. My hope was that it would assign a different class to the thumbnail depending on which alignment I chose, which would allow me to float the thumbnail to the left or right with css.

    Thread Starter colindunn

    (@colindunn)

    Just to clarify, for images inserted into the post they get a special class (alignleft, aligncenter, alignright). I was hoping there was a way to enable that functionality for thumbnail images.

    Thread Starter colindunn

    (@colindunn)

    Did some more resarch, found this page. https://wpengineer.com/the-ultimative-guide-for-the_post_thumbnail-in-wordpress-2-9/. I am trying to make sense of it and see if its possible to accomplish what I am trying to do with this code.

    What you need to do is assign a special class. A lot of people using this will put it within a division layer CSS class element.

    <div class="postthumbnail">
    <?php $image = get_post_meta($post->ID, 'your_thumbnail', true); /* Replace your_thumbnail with the name of the custom field for the image you want to use */ ?>
    <img alt="" src="<?php echo $image ?>" />
    </div>

    For postthumbnail, just classify how you want your image placed. It will not effect your other pics.

    Your p class will not suffice enough to allow your text to wrap around your image.

    Thread Starter colindunn

    (@colindunn)

    Right, but this will align all of my posts in the same way. I want the flexibility to align some thumbnails on the left side on some on the right.

    When inserting an image into your post (rather than a thumbnail) depending on which alignment option you choose (left, center, right) wordpress assigns a different class to that image (alignleft, aligncenter, alignright). I am looking for that same functionality for my thumbnails.

    You need to decide how you want to place your thumbnail images, so chose left or right. Right now, thumbnails are not complex enough unless they start allowing for being able to theme individual posts, beside pages. Would be an idea….right?

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Aligning Thumbnail Images’ is closed to new replies.