Have you tried to use get_children() function?
Edit:
All media attached to any post is treated as children of it. The function wp_get_attachment_image()
will only return images.
With the function get_children()
you’ll be able to get all the media, images or anything else.
In the above link, you can find some examples.
Related Posts:
- What is the alternative to “ when it comes to calling Media (image) files in the ‘attachment.php’ file?
- Remove “Insert from URL” link in Media upload – WP 3.5
- Adding a custom image upload size and making it selected by default?
- Hide custom image sizes from media library
- Hide old attachments from wp media library
- How to register images uploaded via FTP in media library?
- Admin Media grid view images won’t load
- Add custom image sizes to media uploader
- How to upload imagick resource to media in wordpress
- WordPress media upload “HTTP error”
- How do I get images (with a thumbnail preview) to show in search results?
- Adding a querystring to an image URL when clicking ‘insert into post’?
- WordPress automatically adds links to uploaded images
- Get featured image with custom size outside WordPress
- Convert all uploaded PNG files to PNG-8 format
- show/hide attachments
- Edit Image/Image Details – Replace button missing
- An automatic way to crop images of different sizes
- How to automatically convert images to WebP on WordPress?
- Upload images to remote server
- Decrease file size upload in Media
- How to add a class to the attachment images
- PHP/Manual use of images? – 2 Questions
- Rename image uploads replacing “width” and “height” in filename with “medium”, “large”, “small”
- Use Media Library to manage galleries like Nextgen (with folders, albums, collections, tags, categories, terms…)
- Debugging upload problem: What part of WP does actual image-resizing?
- Conditional Statement – check if post has an attachment image
- How to upload a media file via FTP and then create an attachment post with it?
- WP Plugin + OOP: Adding Menu Page doesn’t create required effect
- Assign a picture URL to a page via PHP
- Change logo based on incoming domain
- Different upload path per file type
- How to scale image with equal width and height without distortion?
- Get most recent media upload
- Shortcode Inside Class Not Working
- Convert all images to PNG on file upload
- Escape post image attachments added to template
- Display post image with fancybox
- Get different images for mobile and desktop with php, advanced custom fields without using js and ajax
- Use object in template part
- Customizer – Prefix Class Extension
- Cannot display or echo alt text on featured image
- Recent posts with featured image or fallback image with permalink
- Bulk edit of EXIF data for jpeg images uploaded in the media library?
- Mass update excerpt
- How to prevent XSS alter custom global javascript object & methods in WordPress
- How to open default wp image editor screen dynamically?
- How to get next image with this code from same post?
- Can’t upload image using media_sideload_image
- Searching for any images in media library displays “no media found”
- get_children displaying images removed from the page
- How to get file URL from media library
- “imagejpeg” function is not working in wordpress
- Display image from an external rss feed on wordpress without plugins
- Download images from media library to computer in BULK?
- Why does WP allow to view and media item as a page
- Three Questions with Twenty Eleven theme
- How can I access string value in an array?
- Division by zero error in image.php
- Resize image to specific dimension (X to Y ratio)
- How can I automatically resize up images to fit into all of my registered image sizes
- Upload non-featured image to image field
- Usage of call back function of add_meta_box()
- Why is a wp function used in current PHP namespace’s callback not resolved to global scope?
- Is there a way in WordPress to convert images to WebP without a plugin?
- I’m unable to call img path using single quotes in an array?
- Get the id of all images in a post
- Else/If Statement to Display Photo Descriptions
- Controlling image output size ACF repeater [closed]
- WordPress İmages Upload & Delete Error
- Generate responsive post thumbnails of same size
- Attaching images to posts manually (i.e. with custom code, without the use of an API)
- Get options from database using php class
- How to internationalize header image?
- WordPress api post image raw data without being blank in media library
- WordPress append -1 to the image name
- WordPress loading all local images from specific directory?
- not outputting medium size image URL
- Use PHP Class in WordPress functions
- I have a background-image in css file but don’t show in site.how to fix this prblm. i sent screenshot. thx
- How do I stop an Image Address from loading in the Browser?
- How to add a PHP scripts into WordPress
- Access variable from another class that was passed in constructor
- Proper use of Output Buffer for a whole php clas
- Calling WordPress hook from within a class: call to undefined function error
- How do I get the featured post to share on Social Media and show on Individual Post pages?
- Can’t get data from audio media
- PHP calling function within a class
- What is wrong with assigning values to a WP_List_Table class?
- How to resize an image server-side before upload?
- Snapshot Theme from WooThemes — empty ‘alt’ attribute
- Setting post thumbnail sizes in template file and functions.php
- Determine if only one image attached to a post/page
- Issues separating my Plugin pages into different files
- HTML in PHP problem [closed]
- Adding slides to an existing carousel manually
- Remove default Image Sizes
- Why some images are not allowed to be edited only for thumbnails?
- Use URL query string in img src attribute
- Add/alter image attribute before render