Copied to clipboard

Flag this post as spam?

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


  • Mike 62 posts 274 karma points
    Jan 21, 2014 @ 14:32
    Mike
    0

    Question on fixed image width/height when inserting an image via the editor

    Hi folks,

    Quick question: When inserting an image via the "Insert Picture" icon within the Richtext editor, is it possible to disable, turn off or otherwise stop Umbraco from setting a width and height value on the image when added to the page?

    I ask because it seems to be fixing the height of the images thus causing distortion on responsive layouts.

    Thanks :)

    Mike

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jan 21, 2014 @ 15:26
    Dennis Aaen
    100

    Hi Mike,

    It was me that had to create a responsive layout, would use the media picker datatype every place where it should be possible for the user to add images.

    If you do it this way you can use the package ImageGen (developed by Douglas Robar) for image resizing, and in the last part of this uHangout episode Doug talks about how you can use the ImageGen on a responsive site.

    http://uhangout.co.uk/#/view/_98Q0j2mE40

    I hope that you can use this, or be inspired how you can use images in a responsive solution.

    /Dennis 

  • Mike Chambers 636 posts 1253 karma points c-trib
    Jan 21, 2014 @ 15:43
    Mike Chambers
    0

    you have a couple of other opptions.. you can set config\tinymceConfig.config the <validElements> tag to not allow height and width for <img/> so on save/publish they are stripped (we had limited success with this)

    an alternative is to create a macro to insert the content from the rte, rather than just inserting an umbraco field... and parse the height/width out

    tidied = System.Text.RegularExpressions.Regex.Replace(tidied, @"(<img.*?)(width=""[^""]*"")([^>]*>)", "$1$3", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                    tidied = System.Text.RegularExpressions.Regex.Replace(tidied, @"(<img.*?)(height=""[^""]*"")([^>]*>)", "$1$3", System.Text.RegularExpressions.RegexOptions.IgnoreCase);

    Something like that?

  • Mike Chambers 636 posts 1253 karma points c-trib
    Jan 21, 2014 @ 16:12
    Mike Chambers
    0

    Oh and you might want to check out the mcv hybrid package.. with slimmage and slimresponse... 

    http://our.umbraco.org/projects/developer-tools/hybrid-framework

    http://www.youtube.com/watch?v=BxOx-9jWF7A

  • Mike 62 posts 274 karma points
    Jan 23, 2014 @ 13:28
    Mike
    0

    Hi there Denis/Mike,

    Apologues for the delay in my reply but thank you both very much for the suggestions and the videos - I found them both really interesting. I think for this particular case I can use a media picker as the placement will be in a fixed location within the template rather than, say, a bunch of images in a varying layout within the editor. Based on this it makes sense to use the media picker approach. I will be taking a look at the tinymceConfig file though to see what's possible here as that may be a solution for another project.

    Much appreciated,
    Mike

  • nickornotto 402 posts 905 karma points
    Feb 21, 2014 @ 17:40
    nickornotto
    0

    @Mike thanks the

Please Sign in or register to post replies

Write your reply to:

Draft