Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Adds download functionality to prettyPhoto WordPress plugin. Put the code into yours theme functions.php or the file into mu-plugins folder
add_action('wp_footer','ls_prettyPhoto_Download');
/**
* Adds download functionality to prettyPhoto plugin
* @author lenasterg
*/
function ls_prettyPhoto_Download() {
echo '
<style>.pp_download{ background: #ccc; border-radius: 3px; height: 25px; padding: 4px;}</style>
<script>
jQuery(document).ready(function() {
jQuery("a[rel^=\'prettyPhoto\']").prettyPhoto({
changepicturecallback: function(){
jQuery(".pp_social").append("<span class=\'pp_download_place\'></span>");
$getit= settings.image_markup.replace(/{path}/g,pp_images[set_position]);
jQuery(".pp_pic_holder").find(\'.pp_details .pp_download_place\').html(\'<a class="pp_download" href="\'+pp_images[set_position]+\'" download>Download</a>\');
}
});
});
</script>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment