fix oto's sig by setting min width and height on post images as well
This commit is contained in:
		@@ -144,20 +144,33 @@ document.addEventListener("DOMContentLoaded", () => {
 | 
			
		||||
  document.body.appendChild(lightboxObj.dialog);
 | 
			
		||||
 | 
			
		||||
  function setImageMaxSize(img) {
 | 
			
		||||
    const { maxWidth: origMaxWidth } = getComputedStyle(img);
 | 
			
		||||
    if (img.naturalWidth >= parseInt(origMaxWidth)) {
 | 
			
		||||
      return;
 | 
			
		||||
    const {
 | 
			
		||||
      maxWidth: origMaxWidth,
 | 
			
		||||
      maxHeight: origMaxHeight,
 | 
			
		||||
      minWidth: origMinWidth,
 | 
			
		||||
      minHeight: origMinHeight,
 | 
			
		||||
    } = getComputedStyle(img);
 | 
			
		||||
    console.log(img, img.naturalWidth, img.naturalHeight, origMinWidth, origMinHeight, origMaxWidth, origMaxHeight)
 | 
			
		||||
    if (img.naturalWidth < parseInt(origMinWidth)) {
 | 
			
		||||
      console.log(1)
 | 
			
		||||
      img.style.minWidth = img.naturalWidth + "px";
 | 
			
		||||
    }
 | 
			
		||||
    if (img.naturalHeight < parseInt(origMinHeight)) {
 | 
			
		||||
      console.log(2)
 | 
			
		||||
      img.style.minHeight = img.naturalHeight + "px";
 | 
			
		||||
    }
 | 
			
		||||
    if (img.naturalWidth < parseInt(origMaxWidth)) {
 | 
			
		||||
      console.log(3)
 | 
			
		||||
      img.style.maxWidth = img.naturalWidth + "px";
 | 
			
		||||
    }
 | 
			
		||||
    if (img.naturalHeight < parseInt(origMaxHeight)) {
 | 
			
		||||
      console.log(4)
 | 
			
		||||
      img.style.maxHeight = img.naturalHeight + "px";
 | 
			
		||||
    }
 | 
			
		||||
    img.style.maxWidth = img.naturalWidth + "px";
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  const postImages = document.querySelectorAll(".post-inner img.post-image");
 | 
			
		||||
  postImages.forEach(postImage => {
 | 
			
		||||
    if (postImage.complete) {
 | 
			
		||||
      setImageMaxSize(postImage);
 | 
			
		||||
    } else {
 | 
			
		||||
      postImage.addEventListener("load", () => setImageMaxSize(postImage));
 | 
			
		||||
    }
 | 
			
		||||
    const belongingTo = postImage.closest(".post-inner");
 | 
			
		||||
    const images = lightboxImages.get(belongingTo) ?? [];
 | 
			
		||||
    images.push({
 | 
			
		||||
@@ -171,6 +184,14 @@ document.addEventListener("DOMContentLoaded", () => {
 | 
			
		||||
      openLightbox(belongingTo, idx);
 | 
			
		||||
    });
 | 
			
		||||
  });
 | 
			
		||||
  const postAndSigImages = document.querySelectorAll("img.post-image");
 | 
			
		||||
  postAndSigImages.forEach(image => {
 | 
			
		||||
    if (image.complete) {
 | 
			
		||||
      setImageMaxSize(image);
 | 
			
		||||
    } else {
 | 
			
		||||
      image.addEventListener("load", () => setImageMaxSize(image));
 | 
			
		||||
    }
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  // copy code blocks
 | 
			
		||||
  for (let button of document.querySelectorAll(".copy-code")) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user