Cloudinary+nuxt-picture和动态转换

Cloudinary+nuxt-picture and dynamic transformation

我用的是nuxt-picture和cloudinary。不幸的是,这种联系给我带来了很多问题。 我需要为以下断点生成图像

      xs: 320,
      sm: 720,
      md: 1280,
      lg: 1920,
      xl: 2048,

问题:

网站第一次加载时,会等待图像转换,这对网站性能影响很大。 是否可以使用 cloudinary 预先准备图像并且不等待动态转换?

Cloudinary 支持即时转换 - 即只需修改 URL 参数并请求原始 image/video 的不同版本 - 这就是您第一次看到的情况加载页面。图片的 derived/transformed 版本只有在 Cloudinary 收到请求后才会生成,所以如果你有很多 large/high-quality 原件,它可能需要几秒钟才能即时生成所有内容取决于您请求的确切转换。也就是说,后续请求将 return 来自存储或 CDN 缓存的图像,因此不会遇到任何延迟。

也可以按照您的要求,提前预生成您正在使用的所有转换版本,以避免首次请求延迟。这就是 Cloudinary 调用 Eager Transformations. This allows you to specify the public_id of the original image/video and also the transformations you want to be generated. Generation for images will be a lot quicker, but for videos, it's recommended to perform the eager transformations asynchronously (i.e. in the background) and you can use Eager Notifications 来了解这些内容何时完成并准备好使用的内容。使用 Async Eager Transformations,您可以避免 app/server 在生成急切转换时等待返回响应,这可能会导致超时。使用异步急切转换允许您将生成所需版本的请求发送到 Cloudinary,一旦收到请求,您将立即收到所有请求的转换版本状态为待处理的响应。 Cloudinary 将在后台安排任务以生成请求的转换版本。如果您指定了一个 eager_transformation_url,那么您将在 URL 处收到一个 Webhook 响应,其中包含一个 JSON 有效负载,详细说明所请求的急切转换的结果。

可以为 upload API call or configured in an upload preset 中的新 images/videos 请求急切转换,包括上传到媒体库时使用的上传预设。

对于现有 images/videos,您可以通过 explicit API 方法请求急切转换。