Copied to clipboard

Flag this post as spam?

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


  • Craig100 1136 posts 2523 karma points c-trib
    Jan 25, 2019 @ 12:32
    Craig100
    0

    RTE ConvertImgToSrcSet not working

    Umb V7.13.1, Slimsy V2.0

    Hi,

    Trying to get Slimsy to do it's magic on basic RTE's. Have tried methods here: https://github.com/Jeavon/Slimsy (4 (options)) and here: http://www.jondjones.com/learn-umbraco-cms/umbraco-developers-guide/umbraco-packages/easy-responsive-images-in-umbraco-with-slimsy but neither affect the output in any way.

    This is on a simple blog article page with @inherits Umbraco.Web.Mvc.UmbracoViewPage<BlogPost> Converting @Html.Raw(Model.BodyText) to @Html.ConvertImgToSrcSet(Model.BodyText.ToHtmlString(), true, true) runs but doesn't work while converting to @Html.ConvertImgToSrcSet(Model, "bodyText", true, true) doesn't run at all (cannot convert Umbraco.Web.PublishedContentModels.BlogPost to String)

    Any advice to get this working would be appreciated.

    -Craig

  • MB 113 posts 422 karma points
    Jan 25, 2019 @ 13:15
    MB
    0

    Model.Content ??

  • Nik 1614 posts 7260 karma points MVP 7x c-trib
    Jan 25, 2019 @ 13:23
    Nik
    0

    His use of Model is correct as the view inherits from UmbracoViewPage rather than UmbracoTemplatePage. Because of this there is no need for Model.Content as Model is the correct model :-)

    Nik

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Jan 28, 2019 @ 14:57
    Jeavon Leopold
    0

    Hi Craig,

    Are you using Slimsy v2.1.0-beta2?

    Did you try (although this is obsolete in 2.1):

    @Html.ConvertImgToSrcSet(Model.BodyText, true, true)
    

    Jeavon

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Jan 28, 2019 @ 14:58
    Jeavon Leopold
    0

    Edited above

  • Craig100 1136 posts 2523 karma points c-trib
    Jan 28, 2019 @ 16:05
    Craig100
    0

    Hi Jeavon,

    I used the current package from Nuget V2.0.0 which is the same version as the Umbraco project. Should I be using another version? The site's about to go live.

    Craig

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Jan 29, 2019 @ 09:38
    Jeavon Leopold
    100

    No, that's fine.

    Then I think you should have

    @Html.ConvertImgToSrcSet(Model.BodyText, true, true)
    
  • Craig100 1136 posts 2523 karma points c-trib
    Feb 18, 2019 @ 14:03
    Craig100
    0

    Hi Jeavon,

    Sorry for the late reply, have only just got back to this project. Your suggestion worked fine for where the RTE was accessible directly off the the DocType, thanks.

    Didn't work for the following situation, but managed to sort it with a cast:-

    foreach (var chunk in (IEnumerable<IPublishedContent>)Model.ContentSections)
    {
        <h2>@chunk.GetPropertyValue("title")</h2>
         @Html.ConvertImgToSrcSet(chunk.GetPropertyValue("bodyText"), true, true)  // Didn't work
         @Html.ConvertImgToSrcSet(chunk.GetPropertyValue<IHtmlString>("bodyText"), true, true)  // Works
    }
    

    Thanks

    Craig

  • Craig100 1136 posts 2523 karma points c-trib
    Aug 07, 2019 @ 21:12
    Craig100
    0

    Opening this up again as have noticed that using @Html.ConvertImgToSrcSet causes a severe loss of quality on some images. If I use @Html.Raw then the images look fine, though they're not srcset of course :(

    Just wondered if there was any workaround or technique I should be aware of.

    Cheers,

    Craig

Please Sign in or register to post replies

Write your reply to:

Draft