Answer the question
In order to leave comments, you need to log in
Display product image as url (link to file)?
Hello. There was a need to display the product thumbnail exactly as the address to the file. Now the output goes like this
if ( has_post_thumbnail() ) {
$html = wc_get_gallery_image_html( $post_thumbnail_id, true );
}
<div data-thumb="http://franch.local/wp-content/uploads/2018/03/maxresdefault-100x100.jpg" class="woocommerce-product-gallery__image"><a href="http://franch.local/wp-content/uploads/2018/03/maxresdefault.jpg"><img src="http://franch.local/wp-content/uploads/2018/03/maxresdefault-600x338.jpg" class="wp-post-image" alt="" title="maxresdefault" data-caption="" data-src="http://franch.local/wp-content/uploads/2018/03/maxresdefault.jpg" data-large_image="http://franch.local/wp-content/uploads/2018/03/maxresdefault.jpg" data-large_image_width="" data-large_image_height=""></a></div>
http://franch.local/wp-content/uploads/2018/03/maxresdefault-600x338.jpg
Answer the question
In order to leave comments, you need to log in
1. Display the image immediately as HTML - https://developer.wordpress.org/reference/function...
if ( has_post_thumbnail() ) {
the_post_thumbnail();
}
<?php if ( has_post_thumbnail() ) : ?>
<img src="<?php the_post_thumbnail_url(); ?>" alt="">
<?php endif; ?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question