HTML <img src> 不会加载我的图片

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20033712/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 22:07:46  来源:igfitidea点击:

HTML <img src> wont load my images

htmlimagesrc

提问by Hopeless

Im at a loss with this, im creating a mobile version of my website with jquery, but my images are refusing to load with img src tag.

我对此不知所措,我用 jquery 创建了我网站的移动版本,但我的图像拒绝加载 img src 标签。

<img src="images/me.jpg" width="200" height="267" alt="me">

ive tried using to load my image straight from my website but they're refusing to load also, and moving the image to the same directory as the web page, but still nothing. I just get a box the size of the width and height with the alt text and an image icon in the middle.

我尝试使用直接从我的网站加载我的图像,但他们也拒绝加载,并将图像移动到与网页相同的目录,但仍然没有。我只是得到一个宽度和高度大小的框,中间有一个替代文本和一个图像图标。

I just don't understand whats wrong with it.

我只是不明白它有什么问题。

thanks in advance.

提前致谢。

回答by Marcel

Try to work with the full path as:

尝试使用完整路径作为:

<img src="http://www.yourdomain.com/images/me.jpg" width="200" height="267" alt="me">

<img src="http://www.yourdomain.com/images/me.jpg" width="200" height="267" alt="me">

For test purpose just open http://www.yourdomain.com/images/me.jpgand you should see the image. If it does not work, there must be a compatibility issue with your html/jquery. Just post the rest of your html file and tell us about the jquery plugin(s) you are using ...

出于测试目的,只需打开http://www.yourdomain.com/images/me.jpg,您就会看到图像。如果它不起作用,则一定是您的 html/jquery 存在兼容性问题。只需发布您的 html 文件的其余部分,并告诉我们您正在使用的 jquery 插件...

回答by Hopeless

My images were in fact corrupt or not working properly as I couldn't open them in Photoshop, I had to replace the images.

我的图像实际上已损坏或无法正常工作,因为我无法在 Photoshop 中打开它们,我不得不更换图像。

回答by The Bisto Kid

I have just had the same issue. It was capital letters in the filename. Some pictures were loading some weren't. Some pictures had uppercase .JPGfile extension, and some had lowercase .jpg. My HTML code referenced all of the images using lowercase .jpg.

我刚刚遇到了同样的问题。它是文件名中的大写字母。有些图片正在加载,有些则没有。有些图片的.JPG文件扩展名是大写的,有些图片的文件扩展名是小写的.jpg。我的 HTML 代码使用小写引用了所有图像.jpg

I'm running webserver on my Synology DS.

我在 Synology DS 上运行网络服务器。

回答by P1sces

I just started writing html last night so this is a total noob response because i just had the same problem, but if youre on a windows computer then your slashes in the file location should be back slashes instead of forward slashes like i said- total noob but hope it helps

我昨晚刚开始写 html,所以这完全是一个菜鸟的回应,因为我遇到了同样的问题,但是如果你在 Windows 计算机上,那么你在文件位置的斜杠应该是反斜杠而不是像我说的那样的正斜杠 - 总菜鸟但希望它有帮助

回答by Black

Make sure that you are in the right subdomain in case you are using dev, staging etc.

确保您在正确的子域中,以防您使用 dev、staging 等。

I was wondering too, until I figured out that I am on the staging domain where the image does not exist.

我也想知道,直到我发现我在图像不存在的暂存域中。

Also make sure to clear the cache.

还要确保清除缓存。

回答by Rafikul Alam

  • List item
    1. Just go the image location on your drive
    2. select the image
    3. open it using your favourite browser
    4. go to url bar
    5. copy the location from the url bar
    6. use it in img src=(paste over here)
    7. It will look something like this
    8. img src="file:///C:/Users/Mercy/Documents/WEB%20DEVELOPMENT/HTML5/lion.jpg" alt="Lion profile picture" height="300" width="500"
  • 项目清单
    1. 只需转到驱动器上的图像位置
    2. 选择图像
    3. 使用您喜欢的浏览器打开它
    4. 转到网址栏
    5. 从网址栏中复制位置
    6. 在 img src=(粘贴到这里)中使用它
    7. 它看起来像这样
    8. img src="file:///C:/Users/Mercy/Documents/WEB%20DEVELOPMENT/HTML5/lion.jpg" alt="狮子头像" height="300" width="500"