I have a php variable that fetches woocommerce product images. It works well and I have tested it. Here it is below ...
if( $product instanceof WC_Product ){
$order_img = $product->get_image( 'full' );
}
if I echo $order_img
the variable returns the image as follows
<img width="900" height="1200" src="https://mywebsite.it/.../.../image.jpg" class="attachment-full size-full" alt="" loading="lazy">
What I am doing
What I am trying to do is to have the images taken from the variable as a background in a div. So I did this, obviously it doesn't work because instead of getting just the src link I get the img tag as shown above.
style='background-image: url("<?php echo wp_kses_post($order_img) ?>");'
So in the html I will have this
style='background-image: url("<img width="900" height="1200" src="https://mywebsite.it/.../.../image.jpg" class="attachment-full size-full" alt="" loading="lazy">");'
But I would like to achieve this
style='background-image: url("https://mywebsite.it/.../.../image.jpg");'
So my question is, how can I just retrieve the link from my variable? Is there any way to do it?
所有评论(0)