Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
    
Did you manage to do this? –  user3047 Sep 19 '11 at 21:43
add comment

1 Answer 1

up vote 5 down vote accepted

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.

share|improve this answer
    
is there a plugin which does this? –  user3047 Sep 19 '11 at 21:55
    
@user3047 not that I know, but I hadn't looked... –  Rarst Sep 20 '11 at 8:10
    
Did you manage to make it work? This way? –  user3047 Sep 20 '11 at 16:01
    
@user3047 I merely pointed out obvious error in code back then, I had not tried to implement and test this. –  Rarst Sep 20 '11 at 17:59
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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