You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 16, 2026. It is now read-only.
Imager replaces a DIV (or container) tag by a placeholder image prior to its width URL calculation. The logic of Imager might pleased everybody but users have different contraints:
their CMS is too complicated to hack
for design reasons, you might want to add the placeholder image inside the container
The proposal
The user can decide how the responsive image is treated without altering the internals of Imager.
function Imager() + (Imager.prototype.getPlaceholder + Imager.prototype.processPlaceholder()) = imager-custom.js
<scriptsrc="imager.js"><script>
var imgr = new Imager();
</script>
or
<scriptsrc="imager-container.js"><script>
var imgr = new Imager();
</script>
Pros:
Nothing to configure, just dropping in the good file
Cons:
would not be possible to mix strategies together within a same page
might be more complicated for someone wanting to bake his own strategy
DIY
<scriptsrc="imager.js"><scriptsrc="imager-strategy-replacer.js"><scriptsrc="imager-strategy-container.js"><script>
// by default it will look for the `replacer` one
var imgr = new Imager();
// or we can specify which strategy we want to use
var imgr_sidebar = new Imager({strategy: 'container'});
</script>
Pros:
Freedom to make Imager working the exact way you want
Ability to use different replacements within a same page
Cons:
May be slightly less intuitive than the other proposal
The intention
Imager replaces a DIV (or container) tag by a placeholder image prior to its width URL calculation. The logic of Imager might pleased everybody but users have different contraints:
The proposal
The user can decide how the responsive image is treated without altering the internals of Imager.
Here are the various options to implement that.
One buildfile per strategy
imager-core.js+imager-strategy-replacer.js=imager.jsimager-core.js+imager-strategy-container.js=imager-container.jsfunction Imager()+ (Imager.prototype.getPlaceholder+Imager.prototype.processPlaceholder()) =imager-custom.jsor
Pros:
Cons:
DIY
Pros:
Cons: