Skip to content
This repository was archived by the owner on Aug 6, 2018. It is now read-only.

Commit a0d6ec9

Browse files
author
Krzysztof Hasiński
committed
responsive images for wordpress, v1
1 parent e4e5cc1 commit a0d6ec9

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

web/app/scripts/controllers/main.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,30 @@ angular.module('keymediaApp')
103103
angular.forEach($scope.media, function(v, k) {
104104
if(v.selected) {
105105
if(v.isImage) {
106-
html += '<img src="' + v.file.url + '" />'
106+
html += '<img src="' + v.file.url + '" />';
107+
} else {
108+
html += '<a href="'+v.file.url+'"><img src="'+v.thumbnailUrl+'" /></a>';
109+
}
110+
}
111+
});
112+
win.send_to_editor(html);
113+
};
114+
115+
$scope.attachResponsive = function() {
116+
var win = window.dialogArguments || opener || parent || top;
117+
var imgSrc = $scope.details.file.url;
118+
var html = '';
119+
120+
angular.forEach($scope.media, function(v, k) {
121+
if(v.selected) {
122+
if(v.isImage) {
123+
html += '<span data-picture>\n';
124+
html += ' <span data-src="'+v.thumbnailUrl+'">&nbsp;</span>\n';
125+
html += ' <span data-src="'+v.file.url+'" data-media="(min-width:1000px)">&nbsp;</span>\n';
126+
html += ' <noscript>\n';
127+
html += ' <img src="'+v.file.url+'" />\n';
128+
html += ' </noscript>\n';
129+
html += '</span>\n';
107130
} else {
108131
html += '<a href="'+v.file.url+'"><img src="'+v.thumbnailUrl+'" /></a>';
109132
}

web/app/views/main.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ <h3>
7575
ng-click="attach()"
7676
ng-disabled="!mediaFiltered.length"
7777
">Insert into post</button>
78+
<button class="button media-button button-primary button-large media-button-insert"
79+
ng-click="attachResponsive()"
80+
ng-disabled="!mediaFiltered.length"
81+
">Insert as responsive images</button>
7882
</div>
7983
</div>
8084
</div>

0 commit comments

Comments
 (0)