Skip to content

Commit 241946d

Browse files
committed
Added Crop, Compression and Inline parameter support
1 parent 47e1ffc commit 241946d

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

src/image-engine-angular.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* An AngularJS directive for ImageEngine
55
* Homepage: https://github.com/WURFL/ImageEngine-angular
66
* Authors: Luca Corbo (https://github.com/lucor)
7-
* (c) 2014 - 2016 ScientiaMobile, Inc.
7+
* (c) 2014 - 2017 ScientiaMobile, Inc.
88
* License: MIT
99
*/
1010

@@ -48,17 +48,20 @@ angular.module('image-engine-angular', [])
4848
pc: '@',
4949
m: '@',
5050
f: '@',
51-
r: '@'
51+
r: '@',
52+
cr: '@',
53+
cmpr: '@',
54+
in: '@'
5255
},
5356
template: function (element, attributes) {
5457
return '<div class="img-eng"><img ng-src="{{imgeng_link}}"/></div>';
5558
},
5659
link: function (scope, element, attributes) {
5760
scope.imgeng_link = '';
5861

59-
var allowedAttributes = ['w', 'h', 'pc', 'm', 'f', 'r'];
62+
var allowedAttributes = ['w', 'h', 'pc', 'm', 'f', 'r', 'cr', 'cmpr', 'in'];
6063

61-
scope.$watchCollection('[src, w, h, pc, m, f, r]', function (values, oldValues) {
64+
scope.$watchCollection('[src, w, h, pc, m, f, r, cr, cmpr, in]', function (values, oldValues) {
6265

6366
var src = values.shift();
6467
if (!src) {

test/unit/directiveSpec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,13 @@ describe("Unit: Testing angular directive for ImageEngine", function() {
8585
expect(elt.html()).to.be.equal('<div class="img-eng"><img ng-src="//token.imgeng.in/http://test.com/image2.jpg" src="//token.imgeng.in/http://test.com/image2.jpg"></div>');
8686
});
8787

88+
it('should ignore invalid attribute', function () {
89+
var elt = angular.element('<img-eng src="http://test.com/image.jpg" w="200" in="true" a="invalid"></img-eng>');
90+
compile(elt)(scope);
91+
scope.$digest();
92+
93+
expect(elt.html()).to.be.a('string');
94+
expect(elt.html()).to.be.equal('<div class="img-eng"><img ng-src="//token.imgeng.in/w_200/in_true/http://test.com/image.jpg" src="//token.imgeng.in/w_200/in_true/http://test.com/image.jpg"></div>');
95+
});
96+
8897
});

0 commit comments

Comments
 (0)