Site logo

Archived topic

is it possible to pin the featured image to the bottom left of the page

17 replies · Started by sparkle on November 27, 2022

Viewing posts 1–15 of 18

hi there,

a site i'm working on has a design that shows the featured image for the page pinned to the bottom left, beside the content, on top of the footer. is there a way to do this either with gp elements or in a child theme? i tried hamhandedly adjusting the action in /inc/structure/featured-images.php from add_action( 'generate_after_entry_header', 'generate_post_image' ); to add_action( 'generate_after_before_footer', 'generate_post_image' ); but got no joy. still not great with php.

thanks for your wisdom.

:)

sure... thanks. they want the rounded cutout image currently set as featured to the left edge of the browser at the top of the footer. (i know i'll have some fiddling to do with the margins, mobile layout, etc)...

Can you show us a mockup?

Having a hard time imagining what it would look like.

If you just want to change the position of the featured image, you can disable the featured image for single post at customizer > layout > blog.

Then add a block element using thebefore_footer hook, add a GB image block, enable its dynamic data option, and set it to the featured image.

hm. i've not really used blocks elements. here is their sketch.

Hi there,

can i just clarify:

1. The image will be fixed to the viewport - so it will not scroll out of view?
2. The content beside the image, will that be scrollable ? - i assume Yes, if Yes to #1
3. And this would be for ALL pages?
4. And what happens to it on mobile ?

1. no the image would be at the bottom of the page above the footer, no matter the length of the content.
2. not scrollable.
3. yes, all pages with a featured image.
4. i bet we hide the background image.

Ok, so simple solution would be to:

1. Create a Block Element - Hook.
2. Set the Hook to before_footer
3. Add a GB Image Block and enable its Dynamic Data and set the source to Current Post and the Content to Featured Image.
4. Set the Display Rules to where you require it.

The block will only output the Image if one exists.

It may require some tweaking but if you want to start there.

let me know.

hm. not using generateblocks yet. can i put some php code in the hook? i'm such a slow adopter!

Like this:


<?php
if ( has_post_thumbnail() ){
	global $post;
	echo get_the_post_thumbnail($post->ID, 'post-thumbnail', array( 'class' => 'footer-featured-image attachment-post-thumbnail size-post-thumbnail' ) );
}
?>

The post-thumbnail will output the standard src-set sizes, you can change that if you want specific attachment.
And i added a custom class to the class array of: footer-featured-image which you can use for styling if needed.

For ref:
https://developer.wordpress.org/reference/functions/get_the_post_thumbnail/

ah! thank you!

You're welcome - let us know if you need assistance with positioning :)

i've come back to this project and i'm so close to having what i want... but i'm having zindex issues, i think. how can i get the featured image we moored to the bottom to sit behind the content on the page?

thank you!

Try this CSS:

body > a[title^='Lewiston Auburn Senior College'] {
    z-index: 1;
    position: relative;
}

body > .site {
    z-index: 2;
    position: relative;
}

ahh... yes. perfection. thank you. tho.... i don't understand the first line of the code... is it looking at that page title only? it seems to work for all of the pages, which is great and what i want.

:)

This archived topic is closed to new replies.