We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

path in Phalcon\Tag::image

I have set BaseUri

$url = new \Phalcon\Mvc\Url(); $url->setBaseUri('/test/');

When i use image Tag :

Phalcon\Tag::image("img/logo.png",true);

I got https://www.mydomain.com/test/img/logo.png

Phalcon\Tag::image("/img/logo.png",true);

I got https://www.mydomain.com/test//img/logo.png

But i want https://www.mydomain.com/img/logo.png, how can i do that ?



300
Accepted
answer

Phalcon\Tag takes in account what you have set as baseUri. As far as i know, what you want could work if you set it like

Phalcon\Tag::image("https://www.mydomain.com/img/logo.png",true);

other option would be to set it as <img src="/img/logo.png" /> since you are not using advatange of baseUri anyways

edited Mar '14

try

$url->setBaseUri('/'); $url->setStaticBaseUri('www.mydomain.com');

https://docs.phalcon.io/en/1.2.6/reference/url.html#static-vs-dynamic-uris



7.9k

I need to set $url->setBaseUri('/test/'); for most of my links.

I could find logic that when you begin with a trailing slash, it could understant that you want the root of the path.

Actually i use a CONSTANT : Phalcon\Tag::image(BASE_DOMAIN.'/img/logo.png');