Skip to content

Commit

Permalink
Merge pull request #1282 from GrosPoulet/master
Browse files Browse the repository at this point in the history
Improvement for plug-in : focus_a
  • Loading branch information
GrosPoulet authored Jan 7, 2024
2 parents 9450888 + fbf8bd5 commit a3901ad
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions plugins/focus_a.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var hoverZoomPlugins = hoverZoomPlugins || [];
hoverZoomPlugins.push({
name:'focus_a',
version:'0.1',
version:'0.2',
prepareImgLinks:function (callback) {
var res = [];

Expand Down Expand Up @@ -36,14 +36,16 @@ hoverZoomPlugins.push({
findFullsizeUrl($(this), this.src);
});

$('[style*=url]').filter(function() { return this.style.backgroundImage.indexOf('focus.') == -1 ? false : true }).each(function() {
$('[style*="focus."]').each(function() {
// extract url from style
var backgroundImage = this.style.backgroundImage;
const reUrl = /.*url\s*\(\s*(.*)\s*\).*/i
backgroundImage = backgroundImage.replace(reUrl, '$1');
// remove leading & trailing quotes
var backgroundImageUrl = backgroundImage.replace(/^['"]/, '').replace(/['"]+$/, '');
findFullsizeUrl($(this), backgroundImageUrl);
if (backgroundImage && backgroundImage.indexOf('focus.') != -1) {
const reUrl = /.*url\s*\(\s*(.*)\s*\).*/i
backgroundImage = backgroundImage.replace(reUrl, '$1');
// remove leading & trailing quotes
var backgroundImageUrl = backgroundImage.replace(/^['"]/, '').replace(/['"]+$/, '');
findFullsizeUrl($(this), backgroundImageUrl);
}
});

if (res.length) {
Expand Down

0 comments on commit a3901ad

Please sign in to comment.