简体   繁体   English

Firebase 存储图像未在 nextjs 应用程序中显示

[英]Firebase storage image not displaying in nextjs application

I am using the Next.js template from Vercel and just trying to replace the logo image at the bottom with one that is stored in Firebase storage.我正在使用 Vercel 的 Next.js 模板,并尝试将底部的徽标图像替换为存储在 Firebase 存储中的图像。 I have configured the next.config.js and it does not throw an error but the image is not displayed.我已经配置了 next.config.js 并且它没有抛出错误但是没有显示图像。 It is only showing the image missing placeholder with alt text.它仅显示带有替代文本的图像缺少占位符。 This is my next.config.js这是我的 next.config.js

/**

* @type {import('next').NextConfig}

*/
const nextConfig = {

  images: {
  
  domains: ['firebasestorage.googleapis.com'],
  
  },
  
};
  
  
module.exports = nextConfig;

I can also access the image in my browser.我也可以在我的浏览器中访问图像。

EDIT 14/08/21**编辑 14/08/21**

When I replace the nextjs image tag with a standard html tag the image does load so it seems to be some issue with next.当我用标准的 html 标签替换 nextjs 图像标签时,图像确实加载了,所以它似乎是 next 的一些问题。

Yes I got the same issue and sloved by chagning image tag from NextJs tag to normal html tag.是的,我遇到了同样的问题,并且通过将图像标签从 NextJs 标签更改为普通的 html 标签来解决问题。 this will work, yes you will get an eslint warning but you don't have other opitons Hope this might help这会起作用,是的,您会收到 eslint 警告,但您没有其他选项希望这可能会有所帮助

I solved it using the 'unoptimized' property in nextjs我使用 nextjs 中的“未优化”属性解决了它

                <Image
                    src={item?.categoryImageUrl ?? placeholderImage}
                    alt={item?.categoryName || t("text-card-thumbnail")}
                    width={imageSize}
                    height={imageSize}
                    // quality={100}
                    unoptimized
                    className={`object-cover bg-gray-300 ${
                        variant === "rounded"
                            ? "rounded-md"
                            : "rounded-full"
                    }`}
                />

Read more about this at nextjs unoptimizednextjs unoptimized阅读更多相关信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM