get attachment url for already uploaded images (media library)
-
Hello,
I try to insert a tumblr button to let visitors share images from my posts.
I do not use featured images, so the trick with
wp_get_attachment_image_src ( get_post_thumbnail_id ( $post->ID ), 'full' )
does not work. So I use the following code:$args = array( 'post_type' => 'attachment', 'posts_per_page' => -1, 'post_status' =>'any', 'post_parent' => $post->ID ); $attachments = get_posts( $args ); $img_url=""; if ( $attachments ) { foreach ( $attachments as $attachment ) { $img_url=wp_get_attachment_url( $attachment->ID ); } }
This works so far for all images that I upload directly when creating the post, but is does not work for images hat I choose from the media library.
How can I get the url of those files, too?
Thanks for hints!
Daniel
- The topic ‘get attachment url for already uploaded images (media library)’ is closed to new replies.