Site logo

Archived topic

Post Featured Image Alignment

12 replies · Started by Scott on January 17, 2019

Viewing posts 1–13 of 13

Is there a way for me to have some post with the featured image aligned center and others with the featured image aligned left?

I have some post that I use a 900x400 image and others that use 250x250. The 250x250 looks a lot better aligned left. While the 900x400 looks great centered.

All I see in the Customizer is a global setting for all post.

Hi there,

Are you referring to the single posts?

You'd likely need to write CSS for each of them unless there is some sort of logic as when the pictures are 250x250.

Can you link me to one of those post and I can provide the example CSS?

You can edit the original topic and use the private URL field.

Let me know :)

Yes single post. The images that are 250x250 are all in the same category. Could I use something like this..

add_filter( 'generate_blog_image_attributes','tu_variable_image_sizes' );
function tu_variable_image_sizes( $atts ) {
    // Set up our conditional
    if ( is_post_type_archive( 'store' ) ) {
        $atts[ 'width' ] = 250;
        $atts[ 'height' ] = 250;
        $atts[ 'crop' ] = true;
	$atts[ 'single_post_image_position' ] = 'below-title';
	$atts[ 'single_post_image_alignment' ] = 'left';
    }
    // Return our options
    return $atts;
}

Yup that should work :)

Thanks Leo for the quick response. I found this after I asked the question.

Well I thought this was a fix. When I add this code to my child theme functions.php nothing happens. All images are the same as before I added the code.

But the function to image size is working?

Can you link me to the page in question?

I made an edit to the first post with my url. This post and all the post in this category I would like the image to float left.

Hi Leo, I looked back at some of my previous messages and I probably sounded confusing lol.

Anyways, I was able to find a simple solution like you mentioned above with css.

.category-store .featured-image{float:left}

Ahh ok glad you found a solution :)

The images themselves are 250x250. So I just needed to add the CSS. I think I made things a lot more complicated than it had to be lol.

Thanks for your help man.

No problem at all :)

This archived topic is closed to new replies.