Upload a custom size image - instead of a page link

The goal is when you click "Download for Internet", it downloads this image, unfortunately, when I click the link, it just reloads the page? Any thoughts?

Here is the link to the web page. http://www.redrocketgraphicdesign.co.uk/test/FIRST/product/firststudent1/

This is the code that I have or the moment:

<div class="Downloads">
<h3>Download image</h3>
<a href="<?php $image_id= woocommerce_get_product_thumbnail();
$image_url = wp_get_attachment_image_src($image_id,'web');
echo $image_url=$image_url[0]; ?>"><img src="<?php bloginfo ('template_url' )?>/img/downloadForWeb.png" alt="Download for web" /></a>

+4
source share
2 answers

You have some error in your anchor, empty href is displayed, make sure your php code is correct.

, ador, download :

<a href="/patch/to/your/image" download>Click here to download</a>

:

<div class="Downloads">
<h3>Download image</h3>
<a href="<?php bloginfo ('template_url' )?>/img/downloadForWeb.png">Downlaod for the web</a>
+1

404, woocommerce_get_product_thumbnail() - . , , woocommerce_get_product_thumbnail() wp_get_attachment_image_src(), :

<div class="Downloads">
    <h3>Download image</h3>
    <?php 
    // replace $postID with your post id variable
    // change the 2nd parameter to specify the size of the image to get:
    $image_attrib = wp_get_attachment_image_src( get_post_thumbnail_id($postID),'full');
    ?>
    <a href="<?php echo image_attrib[0]; ?>">
        <img src="<?php bloginfo ('template_url' )?>/img/downloadForWeb.png" alt="Download for web" />
    </a>
</div>

, , , . , , , , URL- .

. (downloadForWeb.png) . downloadForWeb.png URL- , " ". URL-, .

+1

Source: https://habr.com/ru/post/1683900/


All Articles