admin管理员组文章数量:1201201
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
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
- 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 Commented 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 Commented 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 Commented Aug 23, 2015 at 0:34
- Backend (This is for a plugin), I will update my question – Tom Commented Aug 23, 2015 at 0:34
1 Answer
Reset to default 1The 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/
本文标签: plugin developmentHow to list all images used on a specific page
版权声明:本文标题:plugin development - How to list all images used on a specific page? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738628709a2103617.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论