Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Making Image SRC's Absolute in Body Content

Go to End

2 Posts   2598 Views


Community Member, 13 Posts

1 October 2009 at 8:27am

Hi Guys,

I'm trying to make my image tags inside $Content appear with absolute links - so instead of

<img src='assets/Uploads/img.jpg'>

I'd like

<img src=''>

I was hoping the AbsoluteLinks() function - $Content.AbsoluteLinks - would do this, but it just adjusts the hrefs. Is there a quick and easy way to handle this?



Community Member, 712 Posts

1 October 2009 at 10:10am

Edited: 01/10/2009 10:10am

Ironically, the code for Image->getURL() his this comment:

* @todo Refactor to return absolute URL like {@link File}

So, at some point this might be fixed. For now, you'll have to write it out in your template, using the base tag and relative url:

<img src='{$Top.BaseHref}/{$URL}' />

(Not tested, FYI)