dpw70180 2013-12-10 20:47
浏览 111

Wordpress:从图像ID获取描述,标题,alt,文件URL,而图像不是后缩略图

I am writing a shortcode for wordpress

[insert_image id="#NUM"]

Description of the code: The code looks up the image number #NUM and retrieve all the information such as: alt test, description, title, caption, file URL, etc. This information is used to format the image in a way that is similar to Wikipedia (caption on top, then the image, description in the bottom and then the credit to the photographer, all framed in a box with shadow :)).

How I tried to sort this out: Unfortunately online there is a lot of stuff on retrieving thumbnails properties, but little about images that are NOT attached to the post, as it is in this case. As I learned that the image is treated as a post in Wordpress, I tried to retrieve the post whose id is the id of the image, but Wordpress returned NULL. Tried other ways, but got some information on the picture like width and height, but not the information I was looking for. I even looked at the Wordpress code that displays the image properties "add an image"->"media library", but I was not able to find the answer (that code is too advanced for me).

Question: So, I wonder is there anyone that can help me retrieve all the proprieties associated with an image identified just by the id but NOT attached to the post?

  • 写回答

1条回答 默认 最新

  • drpkcwwav20524605 2014-02-06 18:58
    关注

    Try wp_prepare_attachment_for_js

    I have yet to use it, but I know its supposed to grab all the information from an attachment including title, description, alt, caption, etc.

    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度