Copied to clipboard

Flag this post as spam?

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


  • JohnC 37 posts 61 karma points
    Jun 19, 2012 @ 12:51
    JohnC
    0

    Prefix RTE Images

    Hi,

    Does anyone know how i could prefix the url of all images inserted using the RTE within the umbraco backend?

    Basically, I want to presfix them something like /rte/media/123/image.jpg and then using some urlrewriting to process them using imagegen.

     

    Anyone done anything similar to this?

     

    Thanks

    John

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jun 19, 2012 @ 13:48
    Tom Fulton
    0

    Hi John,

    One solution might be to run all your RTE content through some helper function/template, that parses for images and adjusts the path as necessary.  There are a couple methods I've used to do similar functions:

    - Transforming WYSIWYG output with XSLT [blog]

    - Use the HtmlAgilityPack - example:  Wrapping Images using the Html Agility Pack, TinyMce, Umbraco [blog]

    HTH,
    Tom 

  • JohnC 37 posts 61 karma points
    Jun 19, 2012 @ 13:53
    JohnC
    0

    Thanks for that Tom, pretty much exactly what i should be doing, didn't even cross my mind to do that, I was expecting to edit the core and all sorts lol

  • Jan Borup Coyle 8 posts 51 karma points
    Oct 03, 2012 @ 15:02
    Jan Borup Coyle
    0

    I have made a simpe xslt entensive to this.

    <code>

      <msxml:script language="C#" implements-prefix="myfunc">

        <![CDATA[

              public string ImagePrefix(string Value) 

              {

                  return Value.Replace("img src=\"", "img src=\"http://www.mydomain.dk/rte");

              }

              ]]>

      </msxml:script>

    </code>

    Remenber to include :

      xmlns:gitsfunc="urn:myfunc"

      exclude-result-prefixes="msxml .... myfunc"

     

    Cheers

    Jan Borup Coyle

  • Jan Borup Coyle 8 posts 51 karma points
    Oct 03, 2012 @ 15:04
    Jan Borup Coyle
    0

    Forgot the Body render:

              <xsl:value-of select="concat('&lt;![CDATA[ ', myfunc:ImagePrefix(./bodyText),']]&gt;')" disable-output-escaping="yes"/>

Please Sign in or register to post replies

Write your reply to:

Draft