The main problem: you are not viewing the search, so your final one $('span span img')finds everything imgon the page. Here is a feature that fixes other issues as well. Please ask, it makes no sense:
if( $(".image-attach-body").length ) {
$(".image-attach-body a").each(function() {
var $img = $("span span img", this),
width = $img.width();
if(width > 100) {
$img.cjObjectScaler({
destObj: $img.closest(".image-attach-body"),
method: "fit",
});
}
});
}
. if true, jQuery, , null, . , .length , 1. if ( ) , each 0, , ... , , .