I'm using the following code to get vertical images and add class to it but, I don't know why, is not working:
//wrapall div inside a container
$('#page_container .et_pb_column_1 .et_pb_module').wrapAll('<div class="slider-pag_interna">');
//for each img I check height and width and assign some classes
$(".slider-pag_interna div span img ").each(function(){
if ($(this).width() < $(this).height()) {
$(this).parent().parent().addClass("vertical");
}
else{
$(this).parent().parent().addClass("horizontal");
}
});
My html code:
<div id="page_container" class="et_pb_row et_pb_row_0 et_pb_row--with-menu" style="z-index: 3;">
<div class="et_pb_column et_pb_column_1_2 et_pb_column_1 et_pb_css_mix_blend_mode_passthrough et-last-child">
<div class="et_pb_module et_pb_image et_pb_image_0">
<span class="et_pb_image_wrap "><img loading="lazy" src="https://images.unsplash.com/reserve/Af0sF2OS5S5gatqrKzVP_Silhoutte.jpg?ixid=MXwxMjA3fDB8MHxzZWFyY2h8M3x8cGljfGVufDB8fDB8&ixlib=rb-1.2.1&w=1000&q=80" alt="" width="auto" height="auto"></span>
</div>
<div class="et_pb_module et_pb_image et_pb_image_1">
<span class="et_pb_image_wrap "><img loading="lazy" src="https://images.unsplash.com/reserve/Af0sF2OS5S5gatqrKzVP_Silhoutte.jpg?ixid=MXwxMjA3fDB8MHxzZWFyY2h8M3x8cGljfGVufDB8fDB8&ixlib=rb-1.2.1&w=1000&q=80" alt="" width="auto" height="auto"></span>
</div>
<div class="et_pb_module et_pb_image et_pb_image_2">
<span class="et_pb_image_wrap "><img loading="lazy" src="https://www.threebu.it/wp_threebu/wp-content/uploads/2017/06/vertical-farming-chris-jacobs.jpg" width="auto" height="auto"></span>
</div>
<div class="et_pb_module et_pb_image et_pb_image_3">
<span class="et_pb_image_wrap "><img loading="lazy" src="https://images.unsplash.com/reserve/Af0sF2OS5S5gatqrKzVP_Silhoutte.jpg?ixid=MXwxMjA3fDB8MHxzZWFyY2h8M3x8cGljfGVufDB8fDB8&ixlib=rb-1.2.1&w=1000&q=80" alt="" width="auto" height="auto"></span>
</div>
</div>
My test page