Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Matt Smith 77 posts 107 karma points
    Jul 14, 2021 @ 11:40
    Matt Smith
    0

    Decimal places in image sizes

    Hi

    I am seeing image code in pages with a source like this:

     <p><img src="/media/oh4dubgo/be-considerate-on-the-water.jpg?width=500&amp;height=281.25" alt="Image with text reading be considerate on the water" width="500" height="281.25"></p>
    

    The max width in the settings for the image is 500px

    The resizing is leading to decimal places in the image width which is invalid html because it should be an integer.

    is there a setting somewhere to stop the decimal places being added?

    any help gratefully received

    thanks, Matt

  • Joseph 5 posts 74 karma points
    Jul 27, 2021 @ 18:21
    Joseph
    0

    Can you resize the image? I can't imagine .25 of a pixel would matter that much.

  • Tim Miller 32 posts 251 karma points
    Jul 28, 2021 @ 18:10
    Tim Miller
    100

    The easiest fix is to disable the maximum size for inserted images in the settings for the RTE datatype. The images may come in at large sizes, but resizing the image in the RTE uses integers.

    If you want to leave the maximum size, it gets a little more complicated. For example, you could do something like adding an RTE cleanup step to the content saving event that uses a regex to remove the decimals. I probably have some examples that would get you close on this, but it's a little involved.

    You could also create your own media file system that handles all media requests and do this work there. We actually do this and use a CDN for all of our images instead of storing them on the file system. It is by far the most flexible solution but is also by far the most complex.

  • Matt Smith 77 posts 107 karma points
    Jul 29, 2021 @ 08:24
    Matt Smith
    0

    Thank you

    and sometimes the easiest can be best - as we have an approval process for content so we can pick up the inevitable huge images before they are published.

    Thank you Matt

  • Matt Smith 77 posts 107 karma points
    Aug 17, 2021 @ 09:48
    Matt Smith
    0

    Hi all

    I changed this setting in the RTE data type but it hasnt made a difference, I must be missing something? Thanks, Matt

  • Tim Miller 32 posts 251 karma points
    Aug 17, 2021 @ 16:25
    Tim Miller
    1

    First I'd confirm that you are editing the correct data type. Sometimes a new datatype is created depending on how the datatype is added to a doctype. It's probably easiest to go to a content node using the datatype you are trying to modify and go to the Info and click the link to the doctype in the General box. That should open the infinite editor slideout. Then find the property...you get the idea.

    Also, this won't fix existing images, only newly added images.

    Other than that, I'd start asking questions like, what version are you running? I can install a blank instance and do some testing for you.

  • Matt Smith 77 posts 107 karma points
    Aug 19, 2021 @ 11:12
    Matt Smith
    0

    Thank you! that was exactly it, two datatypes with very similar names and I had done the wrong one.

    thanks!

Please Sign in or register to post replies

Write your reply to:

Draft