最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Finding a media attachment post ID from a URL

programmeradmin0浏览0评论

Given I have an image URL

And that the image has previously been saved in the media library

How can I find the media's ID?

i.e.

.jpg might be ID 4

.jpg-scaled-300x300.jpeg is also ID 4

Given I have the URL, how do I find the ID?

function returnMediaID($URL){
   ... // What goes here?
}

$URL = ".jpg";
assertEquals( returnMediaID($URL), 4);
发布评论

评论列表(0)

  1. 暂无评论