0

I like to know if there is already a solution or workaround to zip all images which were uploaded to a WordPress installation. (But only the original images, not the thumbnails.)

Are there internal functions or maybe OS shell scripts? If not, what is the best way to generate such zip-file? Parse all upload-dirs recursively an zip, if the filename doesn't have a thumbnail pattern? Or better grab image list from database and then zip this list?

0

Best way to do it manually. By FTP just download the wp-content/uploads directory. If you want to automate this and the media files zip here is a plugin-

downML - Download Media Library

But it's not updated for more than 2 years. So you have to test it before use it on live site.

There is another solution in my mind. If you can find a PHP Script to zip images from URL you can use this below code to get all the images URLs and create a zip from them. But this script will not very memory friendly.

All images URL code-

$query_images_args = array(
    'post_type'      => 'attachment',
    'post_mime_type' => 'image',
    'post_status'    => 'inherit',
    'posts_per_page' => - 1,
);

$query_images = new WP_Query( $query_images_args );

$images = array();
foreach ( $query_images->posts as $image ) {
    $images[] = wp_get_attachment_url( $image->ID );
}

Now you'll get all the images URLs in $images.

2
  • Thanks for your input. I'll take your wordpress query and combine it with a shell script. My aim is to have a script which runs once a day via cronjob, to serve my users a daily "fresh" archive with all images. – netblognet Oct 24 '16 at 6:31
  • digitalocean.com/community/tutorials/… I think this post can help you. – CodeMascot Oct 24 '16 at 6:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.