Jump to content

$page->url(true) and $page->image_field->url(true)


Zeka
 Share

Recommended Posts

Hi.

By

$page->url(true) 

we can get a url with scheme and hostname. 

But 

$page->image_field->url(true);

returns url without scheme and hostname.

Is it expected behavior or just inconsistency between methods? How do you thinks, should these methods behave the same? 

Link to comment
Share on other sites

To get url with scheme and hostname use

$page->image_field->httpUrl();

It maybe would make sense to provide modifying output of Pagefile::url() via arguments similar to Page::url()
(just to mention: a page is not a file!)

  • Like 2
Link to comment
Share on other sites

2 hours ago, Zeka said:

Is it expected behavior or just inconsistency between methods?

I think you could say it is expected, as these are completely separate methods. The method $page->url() takes an options argument - when you pass 'true' as an argument you are actually setting the 'http' option:

$page->url(['http' => true]);

The method Pageimage::url() takes no options so passing 'true' or any other argument isn't going to modify the way the method works.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...