You are loading a new Publication instead of an existing Publication which is why you do not see the path expected (but get the default path, being /Images
).
Instead of using:
imageBaseUrl = new Publication(_engine.GetSession()).MultimediaUrl;
use:
TcmUri pubUri = new TcmUri("tcm:0-35-1");
imageBaseUrl = new Publication(pubUri, _engine.GetSession()).MultimediaUrl;
Where tcm:0-35-1
is the TCM URI of the Publication you need the Multimedia URL from.
Depending on where you are using this code (Page or Component Template), you could also get the Publication from the Template item using something like this:
RepositoryLocalObject item;
if (package.GetByType(ContentType.Page) != null)
{
Item pageItem = package.GetByType(ContentType.Page);
item = (Page)engine.GetObject(pageItem.GetAsSource().GetValue("ID"));
}
else
{
Item componentItem = package.GetByType(ContentType.Component);
item = (Component)engine.GetObject(componentItem.GetAsSource().GetValue("ID"));
}
if (item != null)
{
Publication publication = (Publication)item.ContextRepository;
}
The Templating Base Project on SDL Tridion World has a lot of useful methods for getting current objecta like the Page or Component you are rendering in the Template and their Publication. When including that in your TBB project, you can simply use a method like GetPublication()
.
Publication.MultimediaUrl
is getting a value from a parent publication? maybe the publication the TBB is defined in?