Site logo

Archived topic

Individual images on solid hero

13 replies · Started by Claire on October 14, 2019

Viewing posts 1–14 of 14

Hi there,

1. Install the Code Snippets plugin:
https://en-gb.wordpress.org/plugins/code-snippets/

2. Create a new snippet and add this - name it Featured Image Shortcode:

function db_feat_img_shortcode() {
    $img_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'large', false );
	return '<img src="' . $img_src[0] . '"/>';
}
add_shortcode( 'db_feat_img', 'db_feat_img_shortcode' );

3. Then in your header element add this shortcode:

[db_feat_img]

Once thats done we can take a look and style it to suit.

Thank you David!

I've done what you've said and this is what I have now:

https://www.athomebeauty.co/diy-home-scents/

So how do I get the image to align at the right-hand side?

Also, when I set the title (inner container) to full width, it's too wide but it seems a bit cramped (when the image will be on the right-hand side).

Is there a way to make the text (blog post titles) & image on the hero a bit wider, but not full-width?

Thanks,

Try this CSS first for the alignment and making the image fill the space on mobile:

@media (min-width: 769px) {
    .inside-page-hero {
        display: flex;
        align-items: center;
    }
    .page-hero img {
        margin-left: 20px;
    }
}
@media (max-width: 768px) {
    .page-hero img {
        width: 100%;
    }
}

Then we can review the spacing if required.

Sorry David,

Where do I put the alignment css code?

I tried to create a new snippet for it, but it just comes up full of errors. I then put it directly in the Elements Header area but that didn't work either.

You can add this CSS:

body .inside-page-hero.grid-container {
    max-width: 1100px;
}

Adjust the max-width property size to suit.

Thank you, just one very last thing - is there a way to align the text side-centre to the image?

Thanks,

Could you link me to a post where i can see the featured image in the header element?
And do you want the text vertically aligned ?

I edited the CSS here to make the vertical alignment

Sorted!

Exactly what I wanted.

Thank you.

You're welcome

This archived topic is closed to new replies.