Reputation: 28086
I use the following syntax in my application so that images are loaded over https or http depending upon how the page was loaded.
<img src="//path_to_image.jpg">
This works fine in Chrome but firefox does not display any images.
What can I do to fix this ?
Upvotes: 0
Views: 224
Reputation: 7616
The // use to support multiple protocol (i.e. http
or https
), these type of URL is known as "protocol relative URLs" and use with complete domain name. Mostly CDN url are used with //.
If you are planning to use // make sure you use full domain url (i.e. //xyz.com/images/path_to_image.jpg). If you just want to use relative path from the root then use single slash (i.e. /)
Following like help you to understand // usage
Two forward slashes in a url/src/href attribute
Upvotes: 2
Reputation: 1059
Using //
will only work with a full URL ('//yourhost.tld/directory/path_to_image.jpg'). In your case one slash /
, should be enough!
Upvotes: 1