【问题标题】:Load instagram image from URL as a BACKGROUND image从 URL 加载 Instagram 图像作为背景图像
【发布时间】:2021-05-10 15:25:17
【问题描述】:

我可以通过在末尾添加 /media/?size=l 轻松地从其 URL 中获取 Instagram 图片,即:

https://www.instagram.com/p/BP73IwIABjh/media/?size=l 

leads to 

https://scontent-lhr8-2.cdninstagram.com/v/t51.2885-15/e35/16228593_1671098819857382_4895739311250472960_n.jpg?tp=1&_nc_ht=scontent-lhr8-2.cdninstagram.com&_nc_cat=102&_nc_ohc=CWyp6r9aeMkAX_yPiOL&edm=AGenrX8BAAAA&ccb=7-4&oh=5674d672622792f99bc091026f209fad&oe=60BFF349&_nc_sid=5eceaa

这很好用,但我想在我的网站上使用这张图片作为背景。但是,如果不访问 URL,则不会拉任何东西。即

<li style="background: #ebeefc url(https://www.instagram.com/p/BP73IwIABjh/media/?size=l) center center no-repeat;background-size:cover;">

这不起作用,只显示背景颜色#ebeefc

是否可以从 instagram URL 加载背景图片,或者可以使用少量 javascript 来预加载图片并拉取转发的 URL?我会使用 instagram API,但似乎无法通过仅使用发布 URL 来以这种方式提取图像。

欢迎任何想法。

【问题讨论】:

    标签: javascript api caching background instagram


    【解决方案1】:

    您必须使用 instagram 的 API。

    如果您在链接的网页上阅读它会显示

    此端点已弃用。请阅读https://developers.facebook.com/docs/instagram/oembed 了解如何迁移您的端点。

    或者您可以下载图像并自行存储。如果您想为您的图像提供唯一的存储空间,我还建议您使用 https://imgur.com/ 之类的东西。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-25
      • 1970-01-01
      • 1970-01-01
      • 2018-08-07
      • 2011-11-03
      相关资源
      最近更新 更多