From: Anthony Talarico Date: Tue, 28 Jun 2016 17:25:58 +0000 (-0400) Subject: testing new jquery method of replacing image with background image X-Git-Tag: v1.0.0^2~114 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=464a5290678f9145c4f8f37389fdae2b15c0bf6d;p=WP-Themes%2Ffrancejourneys.git testing new jquery method of replacing image with background image --- diff --git a/js/app.js b/js/app.js index bc6814e..6a846cb 100644 --- a/js/app.js +++ b/js/app.js @@ -84,14 +84,15 @@ $(document).ready(function () { $("#carousel_ul").css("left", "-210px"); } -// changing the img tag for category view from a source to having a background to make the sizes uniform +// changing the img tag for category view from a source to having a background to make the sizes uniform $(".attachment-shop_catalog").each( function () { - var img_src = $(this).attr("src"); - console.debug(img_src); - $(this).css("height", 175).css("width", 'auto'); - $(this).css("background", 'url(' + img_src + ') no-repeat center center').css("background-size", "cover"); - $(this).removeAttr("src"); -// $(this).attr("src", "").attr("srcset", "" ); + $(this).wrap('
'); }); + $(".image_wrapper").each( function () { + var src = $(this).find('img').attr("src"); + $(this).css("height", 175).css("width", 'auto'); + $(this).css("background", 'url(' + src + ') no-repeat center center').css("background-size", "cover"); + $(this).find('img').remove(); + }); }); diff --git a/js/custom/pageSetup.js b/js/custom/pageSetup.js index 50172e2..e9b4d24 100644 --- a/js/custom/pageSetup.js +++ b/js/custom/pageSetup.js @@ -75,14 +75,15 @@ $(document).ready(function () { $("#carousel_ul").css("left", "-210px"); } -// changing the img tag for category view from a source to having a background to make the sizes uniform +// changing the img tag for category view from a source to having a background to make the sizes uniform $(".attachment-shop_catalog").each( function () { - var img_src = $(this).attr("src"); - console.debug(img_src); - $(this).css("height", 175).css("width", 'auto'); - $(this).css("background", 'url(' + img_src + ') no-repeat center center').css("background-size", "cover"); - $(this).removeAttr("src"); -// $(this).attr("src", "").attr("srcset", "" ); + $(this).wrap('
'); }); + $(".image_wrapper").each( function () { + var src = $(this).find('img').attr("src"); + $(this).css("height", 175).css("width", 'auto'); + $(this).css("background", 'url(' + src + ') no-repeat center center').css("background-size", "cover"); + $(this).find('img').remove(); + }); });