Skip to content

Instantly share code, notes, and snippets.

@lenasterg
Last active June 15, 2017 09:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lenasterg/3f46bf31a04321588d2bc2a01bb4b9be to your computer and use it in GitHub Desktop.
Save lenasterg/3f46bf31a04321588d2bc2a01bb4b9be to your computer and use it in GitHub Desktop.
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