cloudinary 图像在本地与 laravel 8 中的 img 标签配合良好,但在 heroku/production 上不适用——img 在 heroku 上显示空白

Posted

技术标签:

【中文标题】cloudinary 图像在本地与 laravel 8 中的 img 标签配合良好,但在 heroku/production 上不适用——img 在 heroku 上显示空白【英文标题】:cloudinary images works well with img tag in laravel 8 locally but not on heroku/production -- img displays blank on heroku 【发布时间】:2021-12-28 14:26:06 【问题描述】:

我尝试显示从 cloudinary 上传的图片,但使用下面的图片没有显示

<img style="width:auto" src="https://res.cloudinary.com/hrwev09ub/image/upload/v1637132013/dnpic_1637127942.png">

在此之前,我尝试了上面的 img 标签实际上在本地工作,但不是通过 heroku,因为在 heroku 上,我在检查代码源时可以看到如下

<img style="width:auto" src="dnpic_1637127942.png">

我在 heroku 主机上使用带有 cloudinary 的 Laravel 8 -- 有人可以帮助我解决问题或向我推荐解决方案提示。

【问题讨论】:

【参考方案1】:

我是 Danny,在 Cloudinary 的开发者支持团队工作。

我没有很多部署到 Heroku 的经验,所以我无法说明为什么 src 会删除 https://res.cloudinary.com/hrwev09ub/image/upload/v1637132013 部分,但是我确实注意到完整的图像路径会导致 404 .

您能否告诉我当您尝试引用示例图像 (https://res.cloudinary.com/hrwev09ub/image/upload/sample.jpg) 而不指定 style=width:auto 时会发生什么?

这也可能有助于确认您已遵循 Heroku 文档中有关使用 Cloudinary 的所有步骤,可在此处获取:https://devcenter.heroku.com/articles/cloudinary

谢谢, -丹尼

【讨论】:

谢谢丹尼。实际上,使用“res.cloudinary.com/hrwev09ub/image/upload/sample.jpg”在本地主机上运行良好,显示完整路径,但仅在生产中显示文件名。我尝试了很多在线回复均无济于事。

以上是关于cloudinary 图像在本地与 laravel 8 中的 img 标签配合良好,但在 heroku/production 上不适用——img 在 heroku 上显示空白的主要内容,如果未能解决你的问题,请参考以下文章

为啥我收到错误此驱动程序不支持使用 cloudinary-laravel 检索 URL?

无法使用 Heroku 将图像上传到 Cloudinary

未使用 Solidus 和 active_storage 上传到 Cloudinary 的图像

使用Cloudinary,Carrierwave,Ckeditor和Rails Admin时出现问题

如何在节点中使用 multer 将图像上传到 cloudinary 并与其他数据一起表达

使用 markdown 和 cloudinary 的 django 应用程序