-
Notifications
You must be signed in to change notification settings - Fork 222
Open
Description
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:
- 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.
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.js
<script src="imager.js">
<script>
var imgr = new Imager();
</script>or
<script src="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
<script src="imager.js">
<script src="imager-strategy-replacer.js">
<script src="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
Metadata
Metadata
Assignees
Labels
No labels