0

How do I list all the image(s) used on a specific WordPress page. I would like it to include the following if possible,

  • Url to image
  • Name of image
  • Url to thumbnail of the image

[Edit]
I would like to use WordPress itself to get the images, not use something like CURL and extract image urls. Also note this is back-end for a plugin.

[Edit 2]
I need to not only get images within the content of the page, but also images from the theme like a logo in the header, etc. Basically, all images that are on the entire page is what I'm trying to get

4
  • Questions in the form of "please do this for me" rarely receive answers. If you show an example of what you tried, where you researched a possible answer, etc you will find folks more willing to assist.
    – jdm2112
    Aug 23, 2015 at 0:24
  • @jdm2112 Hello, I have googled and done my research on this but so far I am unable to find anything that pulls image's urls from a specific page in WordPress. I do always try to find the answer myself before asking here. I would also like to add that this is not a "do this for me" question but more of a how do I go about accomplishing this
    – Tom
    Aug 23, 2015 at 0:32
  • Are you trying to do this from the front-end or in the back-end, via a plugin for example.
    – jdm2112
    Aug 23, 2015 at 0:34
  • Backend (This is for a plugin), I will update my question
    – Tom
    Aug 23, 2015 at 0:34

1 Answer 1

1

The WP function get_attached_media() should provide the info you need.

If used in this way...

$media = get_attached_media( 'image' );

... the $media var should contain the wp_post objects for all attached images.

Function documentation in the WP Codex: https://developer.wordpress.org/reference/functions/get_attached_media/

1
  • Thank you for your response, I understand that this pulls images from the content but how do I get images outside the content (like logo's within the header and images used by the theme)?
    – Tom
    Aug 23, 2015 at 1:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.