mirror of
				https://github.com/ZetaKebab/kesper.git
				synced 2025-11-04 08:09:49 +00:00 
			
		
		
		
	Fixes variable image width bug
closes #95 - added onload event listeners to images
This commit is contained in:
		@@ -37,19 +37,22 @@
 | 
				
			|||||||
        var $postContent = $(".post-content");
 | 
					        var $postContent = $(".post-content");
 | 
				
			||||||
        $postContent.fitVids();
 | 
					        $postContent.fitVids();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        var casperFullImg = function () {
 | 
					        function updateImageWidth() {
 | 
				
			||||||
            $("img").each(function () {
 | 
					 | 
				
			||||||
            var $this = $(this),
 | 
					            var $this = $(this),
 | 
				
			||||||
                contentWidth = $postContent.outerWidth(), // Width of the content
 | 
					                contentWidth = $postContent.outerWidth(), // Width of the content
 | 
				
			||||||
                    imageWidth = $this[0].naturalWidth; // Original image resolution
 | 
					                imageWidth = this.naturalWidth; // Original image resolution
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (imageWidth >= contentWidth) {
 | 
					            if (imageWidth >= contentWidth) {
 | 
				
			||||||
                $this.addClass('full-img');
 | 
					                $this.addClass('full-img');
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                $this.removeClass('full-img');
 | 
					                $this.removeClass('full-img');
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            });
 | 
					        }
 | 
				
			||||||
        };
 | 
					
 | 
				
			||||||
 | 
					        var $img = $("img").on('load', updateImageWidth);
 | 
				
			||||||
 | 
					        function casperFullImg() {
 | 
				
			||||||
 | 
					            $img.each(updateImageWidth);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        casperFullImg();
 | 
					        casperFullImg();
 | 
				
			||||||
        $(window).smartresize(casperFullImg);
 | 
					        $(window).smartresize(casperFullImg);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user