Post Meta Image called as responsive image
-
I’ve been building a job posting theme locally and and have run into an issue that is stumping me.
I have a custom image field in a form and I’m trying to pull the uploaded image
into a post as a responsive image set. The idea being that in the template can have a responsive loading for these images. I can get the main image that was uploaded to appear but I can’t get the standard responsive images to show. (thumbnail,medium, Large).But I’ve tried every wp call that I know and it will just not pull in the urls of my post_meta image into the srcset.
Any clues on this is appreciated.
Here’s the code I been toying with:
<?php $file_id = get_post_meta( get_the_ID(), '_featured_job_image', true ); ?> <img class="responsive lazyload" src="<?php echo $file_id ?>" srcset="<?php echo wp_get_attachment_image_url( $file_id, 'thumbnail' ) ?>","<?php echo wp_get_attachment_image_url( $file_id, 'medium' ) ?>","<?php echo wp_get_attachment_image_url( $file_id, 'large' ) ?>" sizes="(min-width: 80rem) 50rem, (min-width: 50rem) 38rem, (min-width: 45rem) calc(100vw - 10rem), 100vw" alt="<?php the_title_attribute(); ?>"/>
- The topic ‘Post Meta Image called as responsive image’ is closed to new replies.