Skip to content

Update placeholder to SVG #48

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

Merged
merged 1 commit into from
Jan 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions loading-attribute-polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@
};
}

var temporaryImage =
'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';

/**
* Put the source and srcset back where it belongs - now that the elements content is attached to the document, it will load now
* @param {Object} lazyItem Current item to be restored after lazy loading.
Expand Down Expand Up @@ -159,6 +156,13 @@
// The contents of a <noscript> tag are treated as text to JavaScript
var lazyAreaHtml = noScriptTag.textContent || noScriptTag.innerHTML;

var getImageWidth = lazyAreaHtml.match(/width=[\'\"]([0-9]+)[\'\"]/) || false;
var temporaryImageWidth = getImageWidth[1] || 1;
var getImageHeight = lazyAreaHtml.match(/height=[\'\"]([0-9]+)[\'\"]/) || false;
var temporaryImageHeight = getImageHeight[1] || 1;

var temporaryImage = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 " + temporaryImageWidth + " " + temporaryImageHeight + "'%3E%3C/svg%3E";

if (
!capabilities.loading &&
capabilities.scrolling &&
Expand Down
2 changes: 1 addition & 1 deletion loading-attribute-polyfill.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.