Jump to:

3430 Posts in 1057 Topics by 734 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Which classes rewrite the image paths in HTMLText

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 480 Views
  • tazzydemon
    Avatar
    Community Member
    120 Posts

    Which classes rewrite the image paths in HTMLText Link to this post

    Guys, PLEASE PLEASE HELP!! I'm old(ish), you can see that from my boater!

    I am desperate to fix a jquery mobile issue.

    I have posted a couple of times but with no replies. I have since found the problem but I can't find which classes I have to modify. The are very deep in the CMS.

    What I want is to alter the image insert pane so it alters images to have a leading slash. I then want to alter the save parser and image resizer so that it doesn't remove a slash that is there when it creates a new filename/path.

    Here goes ...I have partly found the answer to the strange rewrites of /assets/image.jpg to assets/image.jpg. In this following real world example the leading slash gets stripped by the class that creates a new image size:

    from
    /assets/images/oldfavourites/Derek-2LR.jpg

    to
    assets/images/oldfavourites/_resampled/resizedimage250333-Derek-2LR.jpg

    I'm not asking for a fix - I can do that but I cant find where.

    Julian

  • tazzydemon
    Avatar
    Community Member
    120 Posts

    Re: Which classes rewrite the image paths in HTMLText Link to this post

    I might add that this was posted to the net, thus showing how annoying this behaviour is. This is a classic case of shutting the door after the horse has bolted:

    http://www.electrictoolbox.com/silverstripe-prefix-img-src-assets-leading-slash/

  • martimiz
    Avatar
    Forum Moderator
    1067 Posts

    Re: Which classes rewrite the image paths in HTMLText Link to this post

    I suppose you are referring to images inserted into the TinyMCE editor, using the SilverStripe sidepanel? This isn't easy to find. It's handled by the javascript file sapphire/javascript/tiny_mce_improvements.js.

    Somewhere around line 624, in the insert() function it says:

    var baseURL = document.getElementsByTagName('base')[0].href;
    var relativeHref = this.href.substr(baseURL.length);

    Thus subtracting the contents of the <base> tag from the href. I suppose you could experiment wth adding a '/' to the front of the relativeHref, if it doesn't start with, say, 'htt'...

    Mind: experiment! I haven't the faintest idea what kind of problems shutting the door in front of this bolting horse might get you into, in this case

  • tazzydemon
    Avatar
    Community Member
    120 Posts

    Re: Which classes rewrite the image paths in HTMLText Link to this post

    In the end I gave up and applied the fix I mentioned since although nuts, it was simple and will survive updates! I still think there should be an option to use root relative urls though (and jquerymobile) falls to bits without them. The fix is now in use at http://boatshow.co.nz

    However thanks for telling me where to look. I still need to find where the image resizer does its work in stripping the leading slash too.

    480 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.