Reputation: 3697
My page content is dynamically created, I am trying to write a script that searches for all images in a container 'image-rounded', and if they are not square, change either the height or width to make them square (based on the size of the smallest edge).
Here is my script so far:
jQuery(function($) {
$('.wrapper-site').find('.image-rounded img').each(function () {
var round_image_width = $(this).width();
var round_image_height = $(this).height();
if(round_image_height > round_image_width) {
$(this).css('height', 'round_image_width');
} else {
$(this).css('width', 'round_image_height');
}
});
});
But currently this does nothing.
Upvotes: 1
Views: 626
Reputation: 6124
$(this).css('height', 'round_image_width');
should be
$(this).css('height', round_image_width);
Same for the height... Happens to the best of us :)
Upvotes: 4