Merge pull request #132 from jeremija/image-width-fix
Fixed bug where image width changes on refresh
This commit is contained in:
commit
144be310a0
|
@ -37,19 +37,22 @@
|
|||
var $postContent = $(".post-content");
|
||||
$postContent.fitVids();
|
||||
|
||||
var casperFullImg = function () {
|
||||
$("img").each(function () {
|
||||
function updateImageWidth() {
|
||||
var $this = $(this),
|
||||
contentWidth = $postContent.outerWidth(), // Width of the content
|
||||
imageWidth = $this[0].naturalWidth; // Original image resolution
|
||||
imageWidth = this.naturalWidth; // Original image resolution
|
||||
|
||||
if (imageWidth >= contentWidth) {
|
||||
$this.addClass('full-img');
|
||||
} else {
|
||||
$this.removeClass('full-img');
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
var $img = $("img").on('load', updateImageWidth);
|
||||
function casperFullImg() {
|
||||
$img.each(updateImageWidth);
|
||||
}
|
||||
|
||||
casperFullImg();
|
||||
$(window).smartresize(casperFullImg);
|
||||
|
|
Loading…
Reference in New Issue