Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
[Solved] jQuery images change
Hi folks.
in order to optimize loading I’m trying to change on the fly images resources for small screens.
Here is my jQuery code:
var $window = $(window);
function checkWidth() {
var windowsize = $window.width();
if (windowsize < 767) {
$('figure a img').each(function(){
$(this).attr('scr').replace(/(.*[0-9]+)\.([a-z]{3})/gi, '$1t.$2');
});
}
}
// Execute on load
checkWidth();
// Bind event listener
$(window).resize(checkWidth);
Unfortunately, I’ve got no results.
Could you tell me where I’m wrong?
Thanks in advance.
Last edited by Pat64 (2012-09-18 09:08:18)
Patrick.
Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.
Offline
Offline
Re: [Solved] jQuery images change
Anyway, IMO body
is loaded after img
, so it will be too late to change their src
. You could try adi_mobile, eventually jointly with etc_query to do it server side.
Offline
Re: [Solved] jQuery images change
@etc: You’re right, man!
@all: Folks, It seems obvious I’m suffering of dyslexia…
I’m using lam_image & adi_mobile plugins in conjunction: these two make the trick :)
Last edited by Pat64 (2012-09-18 09:07:58)
Patrick.
Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.
Offline
Pages: 1