Creare un file ZIP con le immagini da un post WordPress
3 feb 2011, 00:08:23
Visualizzazioni: 1.35K
Voti: 4
Ecco quello che ho fatto finora.
function zip_gallery() { global $post; $images = get_children(array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_mime_type' => 'image', )); if ($images) { $save = $post->post_title; $zip = new ZipArchive; if ($zip->open($save . '.zip', ZIPARCHIVE::CREATE) === true) { foreach ($images as $image) { $file = wp_get_attachment_url($image->ID, 'full', false, false); $filename = pathinfo($file); $zip->addFile($file, $filename); } $zip->close(); } } }
Qualcuno può spiegarmi cosa sto sbagliando?
Commenti
Tutte le risposte alla domanda
1
4
Il metodo ZipArchive->addFile()
si aspetta un percorso locale del file, mentre wp_get_attachment_url()
restituisce un URL. È necessario costruire il percorso locale per il file dall'URL o in altro modo.

Rarst
100K
3 feb 2011 09:09:21
Commenti
Domande correlate
1
risposte
1
risposte
1
risposte
4
risposte
1
risposte