Skip to content

Commit

Permalink
Merge pull request #1096 from GrosPoulet/master
Browse files Browse the repository at this point in the history
Improvement for plug-in: Wired
  • Loading branch information
GrosPoulet authored Feb 25, 2023
2 parents 077b705 + c1ccb50 commit c820f30
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions plugins/wired.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var hoverZoomPlugins = hoverZoomPlugins || [];
hoverZoomPlugins.push({
name:'Wired',
version:'0.2',
version:'0.3',
prepareImgLinks:function (callback) {
var res = [];

Expand All @@ -24,22 +24,21 @@ hoverZoomPlugins.push({
);

$('img[src]').each(function() {
var url = this.src;
try {
// decode ASCII characters, for instance: '%2C' -> ','
// NB: this operation mustbe try/catched because url might not be well-formed
var fullsizeUrl = decodeURIComponent(url);
fullsizeUrl = fullsizeUrl.replace(/\/1:1(,.*?)?\//, '/').replace(/\/16:9(,.*?)?\//, '/').replace(/\/[wW]_?\d+(,.*?)?\//, '/').replace(/\/[hH]_?\d+(,.*?)?\//, '/').replace(/\/[qQ]_?\d+(,.*?)?\//, '/').replace(/\/q_auto(,.*?)?\//, '/').replace(/\/c_limit(,.*?)?\//, '/').replace(/\/c_scale(,.*?)?\//, '/').replace(/\/c_fill(,.*?)?\//, '/').replace(/\/f_auto(,.*?)?\//, '/');
if (fullsizeUrl != url) {
var link = $(this);
if (link.data().hoverZoomSrc == undefined) { link.data().hoverZoomSrc = [] }
if (link.data().hoverZoomSrc.indexOf(fullsizeUrl) == -1) {
const url = this.src;
try {
// decode ASCII characters, for instance: '%2C' -> ','
// NB: this operation must be try/catched because url might not be well-formed
let fullsizeUrl = decodeURIComponent(url);
fullsizeUrl = fullsizeUrl.replace(/\/1:1(,.*?)?\//, '/').replace(/\/16:9(,.*?)?\//, '/').replace(/\/[wW]_?\d+(,.*?)?\//, '/').replace(/\/[hH]_?\d+(,.*?)?\//, '/').replace(/\/[qQ]_?\d+(,.*?)?\//, '/').replace(/\/q_auto(,.*?)?\//, '/').replace(/\/c_limit(,.*?)?\//, '/').replace(/\/c_scale(,.*?)?\//, '/').replace(/\/c_fill(,.*?)?\//, '/').replace(/\/f_auto(,.*?)?\//, '/');
let link = $(this).parents('a');
if (link.length == 0) link = $(this);
if (link.data().hoverZoomSrc == undefined) { link.data().hoverZoomSrc = [] }
if (link.data().hoverZoomSrc.indexOf(fullsizeUrl) == -1) {
link.data().hoverZoomSrc.unshift(fullsizeUrl);
res.push(link);
}
}
}
catch(e) {}
res.push(link);
}
}
catch {}
});

callback($(res), this.name);
Expand Down

0 comments on commit c820f30

Please sign in to comment.