FIX: Ensure images in polls don't cause abrupt scrolling (#13272)

FIX: Ensure images in polls don’t cause abrupt scrolling (#13272)

In some very rare cases, poll options can end up with images that have no dimensions, in which case, navigating to replies in that post stream might result in unexpected scrolling (as the browser loads the images and adjusts its layout).

This ensures that if width/height attributes are missing from an image, the image is forced to display within a 200 by 200 pixels space.

Co-authored-by: David Taylor

diff --git a/plugins/poll/assets/stylesheets/common/poll.scss b/plugins/poll/assets/stylesheets/common/poll.scss
index e012652..4669cd2 100644
--- a/plugins/poll/assets/stylesheets/common/poll.scss
+++ b/plugins/poll/assets/stylesheets/common/poll.scss
@@ -25,9 +25,18 @@ div.poll {
   img {
+    // TODO: remove once disable_image_size_calculations is removed
     // needed to override internal styles in image-sizing hack
     max-width: 100% !important;
     height: auto;
+    // Hacky way to stop images without width/height
+    // from causing abrupt unintended scrolling
+    &:not([width]),
+    &:not([height]) {
+      width: 200px !important;
+      height: 200px !important;
+      object-fit: contain;
+    }
   .poll-info {

GitHub sha: 33cb1b7c

This commit appears in #13272 which was approved by eviltrout and davidtaylorhq. It was merged by pmusaraj.