1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Download button for all gallery images in WooCommerce product page

Discussion in 'eCommerce' started by Rasmus Monsen, Apr 18, 2020.

  1. #1
    Hello,
    SEMrush
    I'm trying to figure out a code to download all gallery images under each and every product with one press of a button.

    Thanks!

    Regards Rasmus
     
    Rasmus Monsen, Apr 18, 2020 IP
    SEMrush
  2. pratik

    pratik Notable Member

    Messages:
    2,259
    Likes Received:
    107
    Best Answers:
    0
    Trophy Points:
    200
    #2
    Do you have FTP access?
     
    pratik, Apr 18, 2020 IP
  3. Rasmus Monsen

    Rasmus Monsen Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #3
    Hi, yes i do.
     
    Rasmus Monsen, Apr 18, 2020 IP
  4. pratik

    pratik Notable Member

    Messages:
    2,259
    Likes Received:
    107
    Best Answers:
    0
    Trophy Points:
    200
    #4
    Option 1: export the product using the wp admin. This way you will get the image urls. Use any free program to download images in bulk from the url.

    Option 2: download images using ftp. Wp content folder
     
    pratik, Apr 18, 2020 IP
  5. Rasmus Monsen

    Rasmus Monsen Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #5
    I think I have to clarify what i'm after. I want the customers to be able to download the pictures from the product page with one button that collects all of that product images. "Download all pictures".
     
    Rasmus Monsen, Apr 18, 2020 IP
  6. JEET

    JEET Notable Member

    Messages:
    3,487
    Likes Received:
    422
    Best Answers:
    16
    Trophy Points:
    235
    #6
    I don't use woocommerce, but it must be storing image names in a table, along with productID.

    So, you need to create a new PHP page, pass the productID in URL.
    Now run a query to get image filenames which have that productID.

    Start a zip file, add individual filenames )full path, not just filenames) from query above to this zip, then either link to the zip, or give it as a download using headers.
     
    JEET, Apr 18, 2020 IP
  7. Rasmus Monsen

    Rasmus Monsen Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #7
    I found this code for fetching images in woocommerce. I'm extremely new to php coding and are happy for all the help i can get.

    <?php
    global $product;

    $attachment_ids = $product->get_gallery_image_ids();

    foreach( $attachment_ids as $attachment_id ){
    echo $image_link = wp_get_attachment_url( $attachment_id );}?>

    I need to extend this PHP to get all files. Any suggestion on how that could look like?
     
    Rasmus Monsen, Apr 19, 2020 IP