I have used ACF plugin to add custom post meta box image field. My custom image field name is homepage_full_width.
How can i display post thumbnail image using this custom field image.
thanks.
I have used ACF plugin to add custom post meta box image field. My custom image field name is homepage_full_width.
How can i display post thumbnail image using this custom field image.
thanks.
You can use image ID as the return type of the ACF custom image field then you can use the wp_get_attachment_image() function to generate the image HTML.
$image = get_field('homepage_full_width');
$size = 'thumbnail'; // (thumbnail, medium, large, full or custom size)
if( $image ) {
echo wp_get_attachment_image( $image, $size );
}
UPDATE
Use image Object as the return type then try
<?php
$imageBg = get_field('homepage_full_width');
$bg = $imageBg ? $imageBg['url'] : '';
?>
<div class="zl-homefullwidth-img parallax_bg skrollable skrollable-between" style="transform: translate3d(0px, 0.382158%, 0px);background-image: url(<?php echo $bg; ?>)"></div>
<div class="zl-homefullwidth-img parallax_bg skrollable skrollable-between" style="transform: translate3d(0px, 0.382158%, 0px);background-image: url(<?php $image = get_field('homepage_full_width'); $size = 'full'; if( $image ) { echo wp_get_attachment_image( $image, $size ); } ?>)"></div> You can do it two ways:
you can use the get_field('homepage_full_width') in your themes php files where you want it, you can see the documention for it here
You can use and shortcode to display it: [acf field="homepage_full_width"]
You can read the documention for the shortcode here
<div id="lead-article" class="post featured-style10 post-header"> <div data-interchange="[<?php echo $lead_article_img_horizontal_src ?>, landscape], [<?php echo $lead_article_img_vertical_src ?>, portrait]" class="zl-homefullwidth-img parallax_bg skrollable skrollable-between" data-bottom-top="transform: translate3d(0px, -20%, 0px);" data-top-bottom="transform: translate3d(0px, 20%, 0px);" style="transform: translate3d(0px, 0.382158%, 0px);background-image: url(<?php echo $lead_article_img_horizontal_src ?>)"></div><?php $image = get_field('homepage_full_width'); ?> to get the image, and where you have your source you can use <?php echo $image['sizes']['large']; ?> where the last is the size you want. or you can get the original file with <?php echo $image['url']; ?>