<IMG> height attribute doesn't work...



  • <img src="http://what.thedailywtf.com/user_avatar/what.thedailywtf.com/tar/120/12008.png" height="50"/>

    <img src="http://what.thedailywtf.com/user_avatar/what.thedailywtf.com/tar/120/12008.png" height="100"/>

    <img src="http://what.thedailywtf.com/user_avatar/what.thedailywtf.com/tar/120/12008.png" height="200"/>

    [spoiler]<img src="http://what.thedailywtf.com/user_avatar/what.thedailywtf.com/tar/120/12008.png" height="100"/>[/spoiler]
    [spoiler][/spoiler]



  • There is something weird going on with the height attribute, but IDK what it is. Those 3 images should all be different sizes, and they are in the Preview...

    Looks ilike the height of the last image 'wins' (except if it's [spoiler]ed...)

    undefined


  • SockDev

    <img src="/uploads/default/16426/59de84ca58b55ec0.png" width="100">
    <img src="/uploads/default/16426/59de84ca58b55ec0.png" width="200">
    <img src="/uploads/default/16426/59de84ca58b55ec0.png" width="300">
    

    Width is the same…


  • SockDev




  • SockDev







  • edit: That still works, at least.


  • SockDev

    <img src="/uploads/default/16021/ae5e4d6753acd9ff.jpg" width="100">
    <img src="/uploads/default/16021/ae5e4d6753acd9ff.jpg" height="200">
    

  • SockDev

    …yep: it's fucked 😆


  • SockDev

    Repro'd and reported at meta.d:

    The onebox needs rebaking…



  • <img src=http://what.thedailywtf.com/uploads/default/_emoji/fa_thumbs_up.png?v=0>


  • SockDev

    Hmm… what if the images are different?


    Well… there's a thing…

    Updated meta.d to include this new info.



  •   def limit_size!(img)
        # retrieve the size from
        #  1) the width/height attributes
        #  2) the dimension from the preview (image_sizes)
        #  3) the dimension of the original image (HTTP request)
        w, h = get_size_from_attributes(img) ||
               get_size_from_image_sizes(img["src"], @opts[:image_sizes]) ||
               get_size(img["src"])
        # limit the size of the thumbnail
        img["width"], img["height"] = ImageSizer.resize(w, h)
      end
    
      def get_size_from_attributes(img)
        w, h = img["width"].to_i, img["height"].to_i
        return [w, h] if w > 0 && h > 0
      end
    

    The first option in the || chain explains what you see when you give both width and height.

    The second option explains how it's using the size of the last image in the post.



  • I'm not saying it was Discourse, but it was Discourse!

    My ruby is rusty, so after I've had a doctor take a look at it, I'll probably defer to your analysis.

    Having a function called get_size_from_image_sizes() seems a bit odd to me. Having said that just looking at the general form of this code

    w, h = (blah1)  || (blah2) || (blah3);
    

    is giving me a headache. I don't think I even want to know what happens if one of those get_size_*() functions returns a single value rather than a pair... :/


  • SockDev

    IIUC, because the three tags point to the same image, whatever it is that has the image sizes only has one entry?


  • :belt_onion:

    <img src="http://what.thedailywtf.com/user_avatar/what.thedailywtf.com/tar/120/12008.png" height="50" class=emoji />

    take that.

    <img src="http://what.thedailywtf.com/user_avatar/what.thedailywtf.com/tar/220/12008.png" height="100%"/>

    <img src="http://what.thedailywtf.com/user_avatar/what.thedailywtf.com/tar/200/12008.png" height="200"/>

    [spoiler]<img src="http://what.thedailywtf.com/user_avatar/what.thedailywtf.com/tar/120/12008.png" height="120"/>[/spoiler]
    [spoiler][/spoiler]


  • :belt_onion:

    no repro, diff sizes working 😉


  • SockDev

    You might want to read the thread properly😛


  • :belt_onion:

    <!-- do i seriously need to undefined my trolling here -->
    I care not to explain these things.



  • Basically: If you don't specify both width and height, Discourse downloads the image and throws out your numbers.


  • :belt_onion:

    <!-- whoosh -->


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.