Copied to clipboard

Flag this post as spam?

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


  • Peter Nielsen 159 posts 257 karma points
    Jul 28, 2019 @ 13:16
    Peter Nielsen
    0

    RTE Media Src empty after upgrade to 8.1 when fetching with API

    Hi people

    I have created a content api where I fetch all properties from all my pages. It worked fine, but then I upgraded from 8.0.2 to 8.1, and then in my Rich Text fields all the media src url come out different. Right now I'm just playing with the Umbraco Starter Kit

    If I look in source in the RTE the tag looks like this:

    <img style="width: 333.49609375px; height: 500px;" src="/media/20e3a8ffad1b4fe9b48cb8461c46d2d0/00000006000000000000000000000000/7371127652_e01b6ab56f_b.jpg?width=333.49609375&amp;height=500" alt="" data-udi="umb://media/20e3a8ffad1b4fe9b48cb8461c46d2d0" />
    

    If I render out inside a Razor view template it works fine.

    But If I try and render out from Umbraco API like this:

    public class PropertyModel {
      public PropertyModel(IPublishedProperty prop, UmbracoContext context) {
    
      try {
        this.Alias = prop.Alias;
        this.SourceValue = prop.GetSourceValue();
        this.DataTypeAlias = prop.PropertyType.DataType.EditorAlias;
    
        var value = this.SourceValue != null ? prop.GetValue() : null;
    
        this.ValueType = value != null ? value.GetType().ToString() : null;
    
        Func<IPublishedContent, Boolean> selector = c => c.IsPublished() && c.IsVisible();
    
        if (this.DataTypeAlias == "Umbraco.MediaPicker") {
          this.Value = value != null ? new SimpleNodeModel((IPublishedContent)value, traverseChildren: false, childSelector: selector) : null;
        } else if (this.DataTypeAlias == "Umbraco.ContentPicker") {
          this.Value = value != null ? new SimpleNodeModel((IPublishedContent)value, traverseChildren: false, childSelector: selector) : null;
        } else if (this.DataTypeAlias == "Umbraco.TinyMCE") {
          this.Value = TemplateUtilities.ParseInternalLinks((string)this.SourceValue, context.UrlProvider).ToString();
          // Here are the line that suddenly fails
    ...
    

    Both SourceValue and Value (whether I use TemplateUtilities.ParseInternalLinks or not) both return this:

    <img style=\"width: 333.49609375px; height: 500px;\" src=\"?width=333.49609375&amp;height=500\" alt=\"\" data-udi=\"umb://media/20e3a8ffad1b4fe9b48cb8461c46d2d0\" />
    

    So my src attribute has been changed to only querystrings.

    I don't know how to troubleshoot here. I really could need some help into which direction I should look.

    I just upgraded Umbraco through NuGet :)

    // Peter

  • Calle Bjernekull 2 posts 92 karma points
    Nov 21, 2019 @ 09:55
    Calle Bjernekull
    0

    Did you find a solution? I'm facing exactly the same problem in a brand new installation (v8.3). I did use Clean Starter Kit, but I don't think that has something to do with it

  • Calle Bjernekull 2 posts 92 karma points
    Nov 21, 2019 @ 10:03
    Calle Bjernekull
    100

    Just found out that there is already a fix in next release (8.4). But you can update Rte.cshtml like explained here: https://github.com/umbraco/Umbraco-CMS/issues/6721#issuecomment-546309669

Please Sign in or register to post replies

Write your reply to:

Draft