什么是热链接图像的合法替代品?
What is a legitimate alternative to hot linking images?
我正在教一组学生有关 Web 开发的知识,我们目前正在学习 AngularJS。我为他们创建的一个练习要求他们从免费和开放的 pokeapi.co 中获取资源。他们可以从 API 取回的数据之一是 URL 精灵宝可梦本身的精灵(小图像)。
过去,我们只是将 link 将 url 直接热 url 到 <img>
标签中。在刚刚尝试调试 403 Forbidden 错误时,我读到了 linking 是多么糟糕的做法。这对我来说很有意义,但我现在有 2 个问题:
- 如果 API 为这张图片提供 URL,我应该用这张 URL 做什么,而不是在我的 HTML?我是否还需要编写一个可以下载该图像的服务器,为图像路径创建一个 link 并改用该 URL ?有没有另一种更容易接受的方法来避免热 linking?
- pokeapi的目的不就是提供数据给人们使用吗?为什么它有限制人们无法使用他们提供的数据的能力?我想这个问题与我的第一个问题密切相关,因为如果有一个我只是没听说过的热 linking 的简单替代方法,那可能会回答我的两个问题。
If the API is providing a URL to this image, what am I supposed to do with this URL other than hot link it in my HTML?
这在the documentation中有解释:
在您请求时在本地缓存资源和图像。
Am I expected to also write a server that can download that image, create a link to the path of the image and use that URL instead?
是
Why does it have restrictions that disable people's ability to use the data they're providing?
因为带宽不是免费的,图像会占用大量带宽。
我正在教一组学生有关 Web 开发的知识,我们目前正在学习 AngularJS。我为他们创建的一个练习要求他们从免费和开放的 pokeapi.co 中获取资源。他们可以从 API 取回的数据之一是 URL 精灵宝可梦本身的精灵(小图像)。
过去,我们只是将 link 将 url 直接热 url 到 <img>
标签中。在刚刚尝试调试 403 Forbidden 错误时,我读到了 linking 是多么糟糕的做法。这对我来说很有意义,但我现在有 2 个问题:
- 如果 API 为这张图片提供 URL,我应该用这张 URL 做什么,而不是在我的 HTML?我是否还需要编写一个可以下载该图像的服务器,为图像路径创建一个 link 并改用该 URL ?有没有另一种更容易接受的方法来避免热 linking?
- pokeapi的目的不就是提供数据给人们使用吗?为什么它有限制人们无法使用他们提供的数据的能力?我想这个问题与我的第一个问题密切相关,因为如果有一个我只是没听说过的热 linking 的简单替代方法,那可能会回答我的两个问题。
If the API is providing a URL to this image, what am I supposed to do with this URL other than hot link it in my HTML?
这在the documentation中有解释:
在您请求时在本地缓存资源和图像。
Am I expected to also write a server that can download that image, create a link to the path of the image and use that URL instead?
是
Why does it have restrictions that disable people's ability to use the data they're providing?
因为带宽不是免费的,图像会占用大量带宽。