Get Image Src for All Images on a Post in WordPress
Get the image src for all images attached to a post.
The PHP function returns an array of image URLs:
function get_all_image_src_by_post_id($post_id) { $photos = get_children( array('post_parent' => $post_id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order') ); $array = array(); if($photos) { foreach($photos as $photo) { $image_attributes = array(); $image_attributes = wp_get_attachment_image_src ( $photo->ID, 'full' ) ; $array[] = $image_attributes[0]; } } return $array; } |
More Related Posts
- [2016/09/22] WordPress Uploaded Images are Blank
- [2016/06/12] Can’t See or Edit Content of Pos...
- [2016/05/31] Get Post Modification Date of a WordPr...
- [2016/06/02] How to Display Most Commented Posts in...
- [2016/05/24] Get Post Permalink on WordPress
- [2016/05/24] Get Post Creation Date of a WordPress ...
- [2016/05/14] How to Display Recent Posts in WordPre...
- [2016/05/24] How to Manually Update WordPress