We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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 http://www.mydomain.com/test/img/logo.png

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

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

But i want http://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("http://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');

http://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');