Support » Fixing WordPress » Need to get the url of every image in a gallery

  • I’m not very familiar with what my options are.

    I don’t know what the appropriate action or filter is that I should be running.

    I am writing a plugin and for it to work properly I need to get all the urls of images in a gallery and put them in an array.

    How can I do this.

    I tried to do it and this isn’t working

    function testing(){
    $args = array(
    ‘order’ => ‘ASC’,
    ‘post_mime_type’ => ‘image’,
    ‘post_parent’ => get_the_ID(),
    ‘post_type’ => ‘attachment’,
    );
    $images =& get_children( $args );
    if ( empty($images) ) {
    // no attachments here
    } else {
    foreach ( $images as $attachment_id => $attachment ) {
    echo get_the_ID().” – “.wp_get_attachment_url( $attachment_id ).”

    “;
    }
    }
    return $allMyShizzle;
    }
    add_action(‘wp_head’,’testing’);

    I think this is pulling media that was added and not gallery images because a different set of images is coming up (probably from an old update)

    Any help would be appreciated I’ve been trying all day searching online and trying different things and gotten nowhere

  • The topic ‘Need to get the url of every image in a gallery’ is closed to new replies.