Вывод картинки товара как url (ссылка на файл)?

Здравствуйте. Возникла необходимость вывести миниатюру товара именно как адрес к файлу. Сейчас вывод происходит так
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

Заранее благодарю за ответ.
  • Вопрос задан
  • 5512 просмотров
Решения вопроса 1
HeadOnFire
@HeadOnFire
PHP, Laravel & WordPress Evangelist
1. Вывести картинку сразу в виде HTML - https://developer.wordpress.org/reference/function...

if ( has_post_thumbnail() ) {
    the_post_thumbnail();
}


2. Вывести только ее урл (в свою разметку) - https://developer.wordpress.org/reference/function...

<?php if ( has_post_thumbnail() ) : ?>
   <img src="<?php the_post_thumbnail_url(); ?>" alt="">
<?php endif; ?>
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы