Copied to clipboard

Flag this post as spam?

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


  • John Walker 41 posts 136 karma points
    Mar 07, 2013 @ 18:02
    John Walker
    0

    Duplicate image src attributes

    umbraco v 4.11.4 

    Hello all,

    When inserting images via the RTE the outputted html for one of my images is:

    <img src="/media/11785/imagename_200x255.jpg"  width="200"  height="255" src="/media/11785/imagename.png" alt="Image Name"/>

    The HTML in my RTE area is:

    <img src="/media/11785/imagename.png" alt="Smiling Florence" width="200" height="255" rel="325,414" />

    To replicate this I first inserted the image, then right clicked the image selected the 'insert image' and amended the dimensions.

    You may notice that the original image is the png and the extra src is a jpg with the set widths appended. I've got a feeling it must be to do with the rel attribute as when I remove that is just shows my single original image.

    Can anyone else replicate this issue? I just want to make sure I'm not going crazy before rasinng a bug report.

     

    John

  • Sebastiaan Janssen 5045 posts 15476 karma points MVP admin hq
    Mar 08, 2013 @ 14:26
    Sebastiaan Janssen
    100

    Yup.. Fixed in 4.11.5 :-) http://issues.umbraco.org/issue/U4-1746

  • John Walker 41 posts 136 karma points
    Mar 08, 2013 @ 17:52
    John Walker
    0

    Great stuff, thought I was going crazy. Will remember to search the bugs list not just forum next time.

     

    Thanks.

  • dimi309 245 posts 579 karma points
    Jul 11, 2013 @ 10:05
    dimi309
    0

     

    Hi Sebastiaan,

    I seem to be having this exact same problem now in v6.1.2 (Assembly version: 1.0.4927.23554) in some of my pages.

    I wonder if it is possible that the bug has resurfaced or if there is something left over in my system (I've been upgrading since v4.0x so, over time, I have passed through almost all versions) which I can clean somehow.

    I have tried rebuilding the xml. That did not do the trick. Sometimes, with consecutive saves of the page after putting a space here and there it goes away but then it sometimes come back. I do not have a sure way to reproduce the problem. It seems to occur in my older pages (the ones that were created in v4.11) but I am not sure.

    Any hints?

    Thanks!

    Dimitri

  • Sebastiaan Janssen 5045 posts 15476 karma points MVP admin hq
    Jul 11, 2013 @ 12:15
    Sebastiaan Janssen
    0

    If you can reliably reproduce it somehow we can have a look. Make sure the src attribute is in the allowed list (umbracoSettings.config):

    <allowedAttributes>src,alt,border,class,style,align,id,name,onclick,usemap</allowedAttributes>

    Also have a look at if you're resizing images or not.

    The code changes were also applied to 6.0.x and 6.1.x so it should work just fine.

    One thing that might be going on is that your old pages already had the double src attribute saved. Those (unfortunately) should be fixed manually.

  • dimi309 245 posts 579 karma points
    Jul 12, 2013 @ 00:59
    dimi309
    0

    Hi Sebastiaan,

    Thanks for the quick reply!

    src is indeed in allowedAttributes. I have tried switching my richtext editor field, in which the problem occurs, to textbox multiple. In there I actually saw the source of an image existing twice. I removed one of the src attributes, and then the image got published properly, passing validation. 

    I then reset the field to richtext, saved and the error resurfaced. I do not know if there is something about some of my pages that has something to do with some leftover of a previous version of Umbraco, but the problem seems to persist, only for some pages though. It looks like it has something to do with TinyMCE. This is the html source of a page which doubles the image src attributes on save:

    <p><img src="/media/427/polyglotlogo.png" alt="Polyglotlogo" class="blogImage"/> Multilingual support package for <a href="http://umbraco.com/" target="_blank" title="Umbraco">Umbraco</a> using a 1-1 multilingual site structure.</p><p>This package adds an option to the context menu of the content tree, which allows the automatic creation of translations of a page, placed in a "folder" under that page. A drop down list box, which is also included in the package, can then be used on the front end by visitors to the site to select their preferred language. When a language is selected, the content is retrieved from one of the above-mentioned translations. If the corresponding translation does not exist, or a specific property of a page has not yet been translated, the content is retrieved from the initial page, which contains the default language.</p><p>The package also supports creating individual translation properties for each property on a page and placing them on that same page. This way, instead of working with translation folders as mentioned above, languages can be managed via tabs in the back office (one tab per supported language).</p><p>More information can be found on <a href="http://our.umbraco.org/projects/backoffice-extensions/polyglot" target="_blank" title="our.umbraco">our.umbraco.org</a> and <a href="http://polyglot.codeplex.com/documentation" target="_blank" title="Codeplex">Codeplex</a>. Also, have a look at this <a href="/en/blog/betterseowithpolyglot" title="Better SEO for the Polyglot package with URL rewriting">blog post</a>, about improving SEO.</p><p>The video below is just a quick overview of how it works. Please read the <a href="http://polyglot.codeplex.com/documentation" target="_blank" title="documentation">documentation</a> in order to find out all the details.</p>

    The first image at the top for example, will produce this problem.

    I am just using textbox multiple for the time being so this has resolved the issue temporarily. In case this problem is not something strange that has just happened to my system, I hope that this information can help towards its resolution.

    Best regards,

    Dimitri

  • Sean Dooley 288 posts 527 karma points
    Jul 18, 2013 @ 12:08
    Sean Dooley
    0

    We have been experiencing the same problem using Umbraco v6.1.0-beta-2. Our workaround was to use the HTML Agility Pack http://htmlagilitypack.codeplex.com/.

    Whenever a document is published we would check any RTE's looking for <img> tags, store a reference to the src attribute, remove any src attributes and then re-add the src attribute.

    HtmlDocument doc = new HtmlDocument();
    doc.LoadHtml(html);
    var imgs = doc.DocumentNode.SelectNodes("//img[@src]");
    if (imgs != null){
    foreach (HtmlNode node in imgs.ToList()){
    string src = node.GetAttributeValue("src", "").Replace("/media", "media");
    node.Attributes.Remove("src");
    node.SetAttributeValue("src", src);
    }
    }
    StringBuilder sb = new StringBuilder();
    using (StringWriter writer = new StringWriter(sb)){
    doc.Save(writer);
    }

    This might not be the solution for everyone but certainly helped in our situation.

  • Sebastiaan Janssen 5045 posts 15476 karma points MVP admin hq
    Jul 18, 2013 @ 16:51
    Sebastiaan Janssen
    0

    I wish I could reproduce this issue, but try as I might.. nothing will lead it to create a duplicate src attribute. 

    And the only thing I'm doing is what I normally do, click the image button, upload a new image, insert it, tried resizing it and everything.. but no luck.

    If you have repro steps I can have another look.

  • Sean Dooley 288 posts 527 karma points
    Aug 02, 2013 @ 15:51
    Sean Dooley
    0

    We are resizing the images in the RTE but not sure when the issue started occurring. As we are using the same image in multiple locations and pages, we were copying and pasting the image from the RTE into the same RTE and other RTE's.]

    If we find out anymore details, we will update this post.

  • dimi309 245 posts 579 karma points
    Aug 02, 2013 @ 16:11
    dimi309
    0

    Hi everyone,

    Just to let you know, since this conversation is still going on, that the issue persists on my system as well (Umbraco 6.1.3 now). I was suspecting at some point that it only had to do with my older pages but, yesterday, I created a new node and some image src attributes  were doubled there also.

    The only workaround I have found for the time being, as I have mentioned, is to switch the relevant properties to 'Textbox multiple' from time to time, when I need to edit the problematic nodes. I will report back if I find a way to reproduce the problem definitively.

    Dimitri

  • dimi309 245 posts 579 karma points
    Aug 02, 2013 @ 23:05
    dimi309
    0

    Hi again guys,

    I believe I have solved this. Please have a look at my pull request:

    https://github.com/umbraco/Umbraco-CMS/pull/72

    When an image cannot be re-sized, its src attribute is being doubled. The attribute is added in the catch clause of the relevant exception, and then it is also be re-added further down in the same method.

    By commenting out the line of the catch clause which adds the src attribute, the issue has been resolved on my machine.

    Sebastiaan, maybe the reason why it was hard to reproduce this problem is that the double src attribute does not actually appear in TinyMCE so there is no way to see it from there. The html source of the page needs to be reviewed. And of course, it does not always happen. Only when there is a failure to resize the image (e.g. when it is an external image, that is not contained in the Umbraco media section).

    Have a nice weekend!

    Dimitri

     

     

  • Ansar 181 posts 291 karma points
    Nov 01, 2013 @ 06:17
    Ansar
    0

    The issue is still with v6.1.6 if you remove "width" for img tag from tinyMceConfig.config

    We need to remove this for responsive sites else all the img added in RTE will have a width attribute and cause problem with responsiveness.

     

Please Sign in or register to post replies

Write your reply to:

Draft