├── .github
└── FUNDING.yml
├── angular-picturefill.js
├── bower.json
├── license.txt
└── readme.md
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: tinacious
4 |
--------------------------------------------------------------------------------
/angular-picturefill.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | angular.module('ng.picturefill', [])
4 | .directive('pictureFill', [function () {
5 | return {
6 | controller: 'PictureFillCtrl',
7 | link: function (scope, elem, attrs) {
8 | elem.attr('data-picture', '');
9 | }
10 | };
11 | }])
12 | .directive('pfSrc', function () {
13 | return {
14 | link: function (scope, elem, attrs) {
15 | elem.attr('data-src', attrs.pfSrc);
16 | }
17 | };
18 | })
19 | .controller('PictureFillCtrl', ['$timeout', function ($timeout) {
20 | $timeout(picturefill);
21 | }])
22 | .filter('trimExt', [function () {
23 | return function (text) {
24 | if (text) {
25 | return text.slice(0, text.lastIndexOf('.')) || text;
26 | }
27 | };
28 | }]);
--------------------------------------------------------------------------------
/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "angular-picturefill",
3 | "description": "An AngularJS directive for Picturefill",
4 | "version": "1.1",
5 | "main": "angular-picturefill.js",
6 | "ignore": [
7 | "readme.md"
8 | ],
9 | "dependencies": {
10 | "picturefill": "~1.2.1",
11 | "angular": "~1.2.0"
12 | }
13 | }
--------------------------------------------------------------------------------
/license.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright 2014 Tinacious Design
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | # AngularJS Picturefill directive
2 |
3 | An AngularJS directive to work with Scott Jehl's [Picturefill](https://github.com/scottjehl/picturefill) plugin for responsive images.
4 |
5 | This directive works with dynamic content populated by the `$scope`.
6 |
7 | See the demo [here](http://tinacious.github.io/angular-picturefill/).
8 |
9 |
10 | ## Usage
11 |
12 | You can download and install into your project using Bower:
13 |
14 | ```
15 | bower install angular-picturefill --save
16 | grunt bower-install
17 | ```
18 |
19 | 1. Download and install with Bower or manually include this directive and [Picturefill](https://github.com/scottjehl/picturefill) in your HTML.
20 | 2. Add `ng.picturefill` as an app dependency.
21 | 3. Use the `picture-fill` directive in your view.
22 | 4. Implement Picturefill as usual. Below is an example implementation but you can specify as many options as you like. The only difference is that `data-src` must be `pf-src` to avoid conflict.
23 | 5. Use the provided `trimExt` filter on all URLs to remove the file extension so that you can append your custom image sizes. Don't forget to put it back.
24 |
25 | **Note:** All images must share the same file extension for this directive to work properly and all file sizes must be available for each file.
26 |
27 | ### With static images
28 |
29 | ```html
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 | ```
39 |
40 | ### With `$scope` data
41 |
42 | The filter `trimExt` is provided for working with `$scope` data.
43 |
44 | ```html
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | ```
56 |
57 | ## Roadmap
58 |
59 | In the future I would like to implement the following:
60 |
61 | - Not requiring all images to have the same file extension
62 |
63 |
64 | ## License
65 |
66 | ### The MIT License (MIT)
67 |
68 | Copyright © 2014 Tinacious Design
69 |
70 | Permission is hereby granted, free of charge, to any person obtaining a copy
71 | of this software and associated documentation files (the "Software"), to deal
72 | in the Software without restriction, including without limitation the rights
73 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
74 | copies of the Software, and to permit persons to whom the Software is
75 | furnished to do so, subject to the following conditions:
76 |
77 | The above copyright notice and this permission notice shall be included in
78 | all copies or substantial portions of the Software.
79 |
80 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
81 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
82 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
83 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
84 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
85 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
86 | THE SOFTWARE.
87 |
88 | [](https://bitdeli.com/free "Bitdeli Badge")
89 |
--------------------------------------------------------------------------------