here is what i have so far.

  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();
          }
      }
  }

can someone shed some light on what im doing wrong.

1 Answer
1

ZipArchive->addFile() method expects local path to file, while wp_get_attachment_url() returns URL. You need to build local path for file from URL or in other way.

Leave a Reply

Your email address will not be published. Required fields are marked *