Skip to content
This repository has been archived by the owner on Aug 5, 2020. It is now read-only.

Commit

Permalink
Merge pull request #274 from mobify/v2.0-ir-updates
Browse files Browse the repository at this point in the history
- updates referenced IR client in bower
  • Loading branch information
jansepar committed May 15, 2014
2 parents e33d6fe + 4532a76 commit 7df97b1
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 39 deletions.
53 changes: 35 additions & 18 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,18 +1,35 @@
2.0.12 - `Capture.prototype.restore` uses self.all() instead of capturedDoc
2.0.11 - Updates `Capture.prototype.restore` to restore the captured doc
2.0.10 - Brings in utils, jazzcat, and imageresize as dependancies using Bower
2.0.9 - Fix for putting Mobify tag above head tag
2.0.8 - Change AMD definitions to UMD in all libs
2.0.7 - Allow specifying quality parameter without it defaulting the format
to JPG.
Added a flag that allows you to turn resizing to auto/on/off.
2.0.6 - Fixed issue where we were not passing in the prefix when
using `render` with an HTML string, causing assets to not get enabled.
2.0.5 - Add API for fixing Anchor Tags on Firefox when using Capturing.
2.0.4 - Fixes iOS 4.3 / Safari 4 issue with placing Mobify tag above <head>.
2.0.3 - Adds a fix to ensure that meta tags do not get created and inserted
into the <head> for older Safari browsers.
2.0.2 - Fixes iOS 4.3 / Safari 4 issue with document.head being undefined.
2.0.1 - Changes getImageURL to grab default options if options object is not
passed to it.
2.0.0 - First stable release of 2.0 API!
2.0.13
- Update image resizer to 1.0.2, which contains changes to default
cache time (from 2 months down to 8 hours).
- Don't patch anchor links on Firefox 29 and above.
2.0.12
- `Capture.prototype.restore` uses self.all() instead of capturedDoc.
2.0.11
- Updates `Capture.prototype.restore` to restore the captured doc.
2.0.10
- Brings in utils, jazzcat, and imageresize as dependancies using Bower.
2.0.9
- Fix for putting Mobify tag above head tag.
2.0.8
- Change AMD definitions to UMD in all libs.
2.0.7
- Allow specifying quality parameter without it defaulting the format
to JPG.
- Added a flag that allows you to turn resizing to auto/on/off.
2.0.6
- Fixed issue where we were not passing in the prefix when
using `render` with an HTML string, causing assets to not get enabled.
2.0.5
- Add API for fixing Anchor Tags on Firefox when using Capturing.
2.0.4
- Fixes iOS 4.3 / Safari 4 issue with placing Mobify tag above <head>.
2.0.3
- Adds a fix to ensure that meta tags do not get created and inserted
into the <head> for older Safari browsers.
2.0.2
- Fixes iOS 4.3 / Safari 4 issue with document.head being undefined.
2.0.1
- Changes getImageURL to grab default options if options object is not
passed to it.
2.0.0
- First stable release of 2.0 API!
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"dependencies": {
"mobifyjs-utils": "git@github.com:mobify/mobifyjs-utils.git#1.0.0",
"jazzcat-client": "git@github.com:mobify/jazzcat-client.git#1.0.0",
"imageresize-client": "git@github.com:mobify/imageresize-client.git#1.0.0"
"imageresize-client": "git@github.com:mobify/imageresize-client.git#1.0.2"
},
"devDependencies": {

Expand Down
39 changes: 24 additions & 15 deletions build/mobify.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ ResizeImages.dataUriWebpDetect = function(callback) {
// through the Mobify Image resizer:
// http://ir0.mobify.com/webp/http://upload.wikimedia.org/wikipedia/commons/c/ca/1x1.png
image.src = 'data:image/webp;base64,UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAABBxAR/Q9ERP8DAABWUDggGAAAADABAJ0BKgEAAQABgBwlpAADcAD+/gbQAA==';
}
};

/**
* Detect WEBP support sync and async. Do our best to determine support
Expand Down Expand Up @@ -283,19 +283,19 @@ ResizeImages._shouldResize = function(document) {
// Ideal viewport when width=device-width and the intial-scale is 1 or more
// (in that case it's just zoomed)
if (metaViewport['width'] && metaViewport['initial-scale']) {
initialScale = parseInt(metaViewport['initial-scale']);
initialScale = parseInt(metaViewport['initial-scale'], 10);
return initialScale >= 1 && metaViewport['width'] == 'device-width';
}

return false
return false;
};

/**
* Processes options passed to `resize()`. Takes an options object that
* potentially has height and width set in css pixels, returns an object where
* they are expressed in device pixels, and other default options are set.
*/
ResizeImages.processOptions = function(options) {
ResizeImages.processOptions = function(options) {
var opts = Utils.clone(ResizeImages.defaults);
if (options) {
Utils.extend(opts, options);
Expand All @@ -304,7 +304,7 @@ ResizeImages.processOptions = function(options) {
// A null value for `resize` triggers the auto detect functionality. This
// uses the document to determine whether images should be resized and sets
// it as the new default.
if (opts.resize == null && options.document) {
if (opts.resize === null && options.document) {
var resize = ResizeImages._shouldResize(options.document);
ResizeImages.defaults.resize = opts.resize = resize;
}
Expand Down Expand Up @@ -383,7 +383,7 @@ ResizeImages.resize = function(elements, options) {
ResizeImages.restoreOriginalSrc = function(event) {
var origSrc;
event.target.removeAttribute('onerror'); // remove ourselves
origSrc = event.target.getAttribute('data-orig-src')
origSrc = event.target.getAttribute('data-orig-src');
if (origSrc) {
event.target.setAttribute('src', origSrc);
}
Expand All @@ -392,18 +392,27 @@ ResizeImages.restoreOriginalSrc = function(event) {
var capturing = window.Mobify && window.Mobify.capturing || false;

ResizeImages.defaults = {
proto: '//',
host: 'ir0.mobify.com',
projectName: "oss-" + location.hostname.replace(/[^\w]/g, '-'),
sourceAttribute: "x-src",
targetAttribute: (capturing ? "x-src" : "src"),
webp: ResizeImages.supportsWebp(),
resize: true,
onerror: 'ResizeImages.restoreOriginalSrc(event);'
cacheHours: 8,
proto: '//',
host: 'ir0.mobify.com',
projectName: "oss-" + location.hostname.replace(/[^\w]/g, '-'),
sourceAttribute: "x-src",
targetAttribute: (capturing ? "x-src" : "src"),
webp: ResizeImages.supportsWebp(),
resize: true,
onerror: 'ResizeImages.restoreOriginalSrc(event);'
};

return ResizeImages;
ResizeImages.profiles = {
SHORT_CACHE: {
cacheHours: 2
},
LONG_CACHE: {
cacheHours: 168
}
};

return ResizeImages;
}));

},{"../mobifyjs-utils/utils.js":3}],2:[function(require,module,exports){
Expand Down
2 changes: 1 addition & 1 deletion build/mobify.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mobifyjs",
"version": "2.0.12",
"version": "2.0.13",
"description": "Mobify.js is an open source library for improving responsive sites by providing responsive images, JS/CSS optimization, Adaptive Templating and more.",
"author": "Mobify <dev@mobify.com>",
"devDependencies": {
Expand Down
22 changes: 19 additions & 3 deletions www/v2/docs/image-resizer.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ ir0.mobify.com will serve a 302 redirect back to the original image location.**
- `targetAttribute`: The attribute to set witht he resized url. Defaults to
"x-src" when capturing, and "src" without capturing.
- `cacheHours`: Sets the length of time for the image(s) to be cached on the CDN.
The default is 2 months.
- `format`: Output format of the image(s) being resized. Defaults to original
format, except non-animated gifs, which are converted to png.
The default is 8 hours.
- `format`: Output format of the image(s) being resized, one of 'jpg', 'png,
'webp' or the special format specifier 'q', which will return an image in its
original format, but allows quality to be specified on its own. Defaults to
original format, except non-animated gifs, which are converted to png.
- `quality`: An integer from 1-100 used as a quality parameter when encoding
jpg and webp images, can only be set along with the `format` parameter.
- `maxWidth`: Maximum width of the image(s) being resized (in CSS pixels).
Expand All @@ -79,6 +81,20 @@ ir0.mobify.com will serve a 302 redirect back to the original image location.**
once. Use this option if you change an image and need to break Image Resizer's
cache.

**Profiles**
Some options presets are provided on `ResizeImages.profiles`

- `SHORT_CACHE` sets a 2 hour cache lifetime on the resulting asset, for images
that might change without changing URL.
- `LONG_CACHE` sets a one week cache lifetime for assets that will remain valid
for longer periods.

You can combine these profiles with your own options objects like so:

var options = Utils.extend({
< your options >
}, ResizeImages.profiles.SHORT_CACHE);

**Example**

There are many examples using Image Resizer on the
Expand Down

0 comments on commit 7df97b1

Please sign in to comment.