Posibilidad de descargar imagen con Easy Gallery
2 seguidores
Hola, he encontrado este script para hacer galerías de fotos. Es el típico que se oscurece la pantalla y en el centro sale la imagen. La pregunta es ¿alguien sabe cómo añadir un botoncico para poder descargar la imagen que se abre?
Saludos
mada4k
La pregunta es cómo añadir el botón o cómo hacer la funcionalidad para descargar?
Para la funcionalidad llamas a un PHP enviando por GET el nombre de la imagen:
$file = $_GET["file"];
header("Content-Type: application/octet-stream");
header('Content-Disposition: attachment; filename="'.$file.'"');
readfile($file);
die;
?>
Para añadir el botón tendrás que editar el código del JS. Busca todas las acciones del botón close, duplica el código y renombra por download, así tendrás esa funcionalidad para cuando quieras.
Por ejemplo, si encuentro la línea:
this.showClose = true; // true to display the Close button, false to hide
Creo otra debajo con:
this.showDownload = true; // true to display the Download button, false to hide
Otra más...
var objClose = this.doc.createElement("a");
objClose.setAttribute('id','lbClose');
objClose.setAttribute((this.ie ? 'className' : 'class'), this.theme);
objClose.setAttribute('href','#');
objBottomNav.appendChild(objClose);
Duplico:
var objDownload = this.doc.createElement("a");
objDownload.setAttribute('id','lbDownload');
objDownload.setAttribute((this.ie ? 'className' : 'class'), this.theme);
objDownload.setAttribute('href','#');
objBottomNav.appendChild(objDownload);
etc...
Luego el CSS del mismo modo:
#lbClose { width: 64px; height: 28px; float: right; margin-bottom: 1px; }
Duplico:
#lbDownload { width: 64px; height: 28px; float: right; margin-bottom: 1px; }
Y cuando ya lo tengas todo, edita el CSS para posicionar correctamente el botón de download.
Víctor Sánchez
Mil gracias!!! esta tarde lo pruebo sin falta!!
Saludos