如何让我的用户下载在我的博客文章中上传的图片?
页面上禁用了右键单击功能。因此用户无法使用右键单击下载。
我想创建一个链接或按钮,如
<a class="btnlink4" href="#">Download this Image.</a>
通常,我的博文只有一个图片。
对于上传到Blogger本身的图像,在图像URL末尾添加查询参数?dl=1
将导致强制下载它们。另一种方法是,通过在图像URL(又名-d
)中的大小调整参数后面加上s1600
,例如 -
<a href="https://1.bp.blogspot.com/-k1bwGQauV6I/WLyURMAuU9I/AAAAAAAAAD0/k_ZcX4sr_bENoB2P3P8MTEfN-ymfa3_ugCLcB/s1600/en_Contempo.jpg?dl=1">Download this Image.</a>
<a href="https://1.bp.blogspot.com/-k1bwGQauV6I/WLyURMAuU9I/AAAAAAAAAD0/k_ZcX4sr_bENoB2P3P8MTEfN-ymfa3_ugCLcB/s1600-d/en_Contempo.jpg">Download this Image.</a>
您可以使用download
标签的href
属性的anchor
属性。它将下载图像。首先,当您上传图片时,您会获得上传图片的链接:
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-GfBiEDZvfKo/W9iND3nZniI/AAAAAAAAASY/ZEo4RIBwDkQBOQsEPecPZJ9pBQDiqOdcgCPcBGAYYCw/s1600/Google%2BAdSense.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;">
<img border="0" data-original-height="161" data-original-width="293" height="174" src="https://3.bp.blogspot.com/-GfBiEDZvfKo/W9iND3nZniI/AAAAAAAAASY/ZEo4RIBwDkQBOQsEPecPZJ9pBQDiqOdcgCPcBGAYYCw/s320/Google%2BAdSense.jpg" width="320" />
</a>
</div>
您需要做的是,在锚标记的末尾添加单词download
,图像URL为href
,如下所示:
<a href="IMAGE-URL" download>Download Image</a>
^^^^^^^^
样品在这里:
This is the image:
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-GfBiEDZvfKo/W9iND3nZniI/AAAAAAAAASY/ZEo4RIBwDkQBOQsEPecPZJ9pBQDiqOdcgCPcBGAYYCw/s1600/Google%2BAdSense.jpg" imageanchor="1" style="clear: right; margin-bottom: 1em; margin-left: 1em;">
<img height="174" src="https://3.bp.blogspot.com/-GfBiEDZvfKo/W9iND3nZniI/AAAAAAAAASY/ZEo4RIBwDkQBOQsEPecPZJ9pBQDiqOdcgCPcBGAYYCw/s320/Google%2BAdSense.jpg" width="320" />
</a>
</div>
Download link
<a href="https://3.bp.blogspot.com/-GfBiEDZvfKo/W9iND3nZniI/AAAAAAAAASY/ZEo4RIBwDkQBOQsEPecPZJ9pBQDiqOdcgCPcBGAYYCw/s320/Google%2BAdSense.jpg" download>Click here to download it</a>