Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed empty src attribute from img tag. Fixes #276 #287

Closed
wants to merge 1 commit into from
Closed

Removed empty src attribute from img tag. Fixes #276 #287

wants to merge 1 commit into from

Conversation

MazeChaZer
Copy link

The empty src attribute triggers strange behavior in IE 8 and is a bad practice in general.
If lightbox is used on http://example.com/product/123 IE 8 makes a request to http://example.com/product/ to fetch the image. This caused Exceptions invisible in the browser that we needed half a day to track down.
Chrome and Safari (at least in older versions) try to load the image from http://example.com/product/123, so this can double the traffic on your website in the worst case.
See also http://www.nczonline.net/blog/2009/11/30/empty-image-src-can-destroy-your-site/

@the-real-tokai
Copy link
Contributor

An "img" tag without "src" is not valid, see: http://dev.w3.org/html5/spec-preview/the-img-element.html

"The src attribute must be present, and must contain a valid non-empty URL potentially surrounded by spaces referencing a non-interactive, optionally animated, image resource that is neither paged nor scripted."

I did a similar patch (see pull request #280) which adds a dummy "data:" url to the empty src to fix the issues in the browsers. This is not ideal either though. IMHO the whole tag should first be injected to the html when it is actually needed. I guess that requires a slightly more elaborate patch than our both solutions. ;)

@rulin132
Copy link

maybe instead of removing the src tag, which may fix one issue, but introduce other issues, might be better to use the old blank gif trick. a base64 1x1 gif will probably be the best solution if no valid src URL has been provided.

@MazeChaZer
Copy link
Author

I agree. Closing this pull request in favor of #280.

@MazeChaZer MazeChaZer closed this Sep 22, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants