0

Ok actually i am building a wordpress base site in which people came to download the wallpapers, its working all over but when i insert the image ahref tag its actually open the image not provide the download button,

I use

<a href="image url">button</a>

but with this the image opened in browser not provide the download box.

Is there any way to download the image, or any plugin to do that .....

Also checked this one but not works ..... href image link download on click

Community
  • 1
  • 1
Amir
  • 200
  • 3
  • 12

2 Answers2

0

It is possible by using the plugin:

http://wordpress.org/extend/plugins/download-shortcode/

or

Try this code snippet

if ( $attachments = get_posts( array(
    'post_type' => 'attachment',
    'post_mime_type'=>'image',
    'numberposts' => -1,
    'post_status' => 'any',
    'post_parent' => $post->ID,
) ) );
foreach ( $attachments as $attachment ) {
    echo '<a href="javascript:void(0);"
        onclick="document.execCommand(\'SaveAs\', true, \'' . get_permalink( $attachment->ID ) . '\');">
        Download This Wallpaper</a>';
}

Or by using the caption tags

[caption id="" align="alignnone" width="500" caption="Download Here"]<a href="/wp-content/uploads/whateverimage.jpg"><img alt="alt_text_here" src="/wp-content/uploads/whateverimage.jpg" title="My Title of Image" width="500" height="331" /></a>[/caption]

not tested..

Vaibs_Cool
  • 6,126
  • 5
  • 28
  • 61
0

I think you should try this one:

<a href="<?php bloginfo('template_url'); ?>/images/" download="ImageName" title="ImageName">
    <img src="image url" alt="ImageName">
</a>

thanks.

Krunal Shah
  • 2,083
  • 12
  • 27