【发布时间】:2021-07-11 14:42:05
【问题描述】:
如果我使用类似的东西:
import React from 'react'
import {Image} from 'cloudinary-react';
export const Logo = () => {
return (
<Image
publicId="logo.png"
crop="limit"
width={170}
height={16}
/>
);
}
export default Logo;
结果我们得到
<img src="http://res.cloudinary.com/blablabla/image/upload/c_limit,h_16,w_170/v1/logo.png">
img 标记中没有 width 和 height 属性。
这就是为什么 Google PageSpeed Insights 抱怨页面上有许多 img 标签:
有没有办法解决这个问题?
【问题讨论】:
-
请看看我的回答,也许它会帮助你:)
-
您在
中传递的参数指的是添加到输出 URL (c_limit,h_16,w_170) 但与 HTML 无关的 Cloudinary 转换标签宽度/高度。如果你想设置 属性,那么@Sowam 的第一个代码示例就可以了。
标签: reactjs cloudinary