philomena-dev / philomena

Next-generation imageboard
GNU Affero General Public License v3.0
90 stars 34 forks source link

Scaled images uses at most the 'large' version #2

Closed marktaiwan closed 4 years ago

marktaiwan commented 4 years ago

Describe the bug Upon page load, images with a dimension far smaller than the viewport is displayed using the 'large' version, instead of 'full'.

To Reproduce Steps to reproduce the behavior:

  1. Go to https://derpibooru.org/images/798716
  2. Click on the image
  3. Image flickers as the 'large' version is hidden and the 'full' version is loaded

Expected behavior Expect only the 'full' version of the image to be used.

Desktop (please complete the following information):

Additional context The bug appears to be introduced in 49f0476

The function pickAndResize(elem) in image_expansion.js expects the element passed in (#image_target) to have the the 'data-image-size' and 'data-mime-type' attributes: https://github.com/philomena-dev/philomena/blob/49f0476ad84b0dea91a7a9bea9db758f45a9af84/assets/js/image_expansion.js#L62-L63 However, the attributes were added to the parent element .image-show-container instead, causing the values NaN and undefined to be assigned to the variables, leading to failing of the final check in selectFunction: https://github.com/philomena-dev/philomena/blob/49f0476ad84b0dea91a7a9bea9db758f45a9af84/assets/js/image_expansion.js#L42-L52

liamwhite commented 4 years ago

03897624fe83e82908d5fcc36cf4e23c477ba43b