【问题标题】:How to get the URL of an uploaded image in Cloudinary如何在 Cloudinary 中获取上传图片的 URL
【发布时间】:2020-03-02 21:20:11
【问题描述】:

如何在 Cloudinary 中获取上传图像的 URL,以便在使用 PHP 上传文件时将其保存在数据库中?

【问题讨论】:

    标签: cloudinary


    【解决方案1】:

    如果您使用Cloudinary PHP SDK to perform the upload,对 SDK 的 Upload 方法调用的响应将包含新上传图像的元数据

    这里的文档中有一个示例: https://cloudinary.com/documentation/php_image_and_video_upload#upload_response

    Array
    (
      [public_id] => c87hg9xfxrd4itiim3t0
      [version] => 1571218607
      [signature] => f8645b000be7d717599affc89a068157e4748276
      [width] => 864
      [height] => 576
      [format] => jpg
      [resource_type] => image
      [created_at] => 2017-06-23T13:59:18Z
      [bytes] => 120253
      [type] => upload
      [url] => http://res.cloudinary.com/demo/image/upload/v1571218607/c87hg9xfxrd4itiim3t0.jpg
      [secure_url] => https://res.cloudinary.com/demo/image/upload/v1571218607/c87hg9xfxrd4itiim3t0.jpg
    )
    

    url 和 secure_url 将返回原始图像,但是为了访问图像的派生版本,您还应该存储 public_id、resource_type、type、format、version 所以在应用程序中使用图像时,您可以正确跟踪资产并将必要的值传递给 cl_image_tag() 或 cloudinary_url()。

    【讨论】:

      猜你喜欢
      • 2019-03-11
      • 2021-10-27
      • 2016-03-10
      • 2013-12-18
      • 2016-09-20
      • 2021-09-29
      • 2020-12-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多