eZ Community » Forums » eZ Publish 5 Platform » How to instruct eZ Publish 5 to work...
expandshrink

How to instruct eZ Publish 5 to work with relative URL on ezimage rendered images?

How to instruct eZ Publish 5 to work with relative URL on ezimage rendered images?

Monday 05 January 2015 6:11:35 pm - 6 replies

Using eZ Publish 2014.11, all ezimages are generated with an absolute (with: "http://" instead of /var/...) URL, e.g.:

This can be seen live at: https://www.lescheminsdeferengagent.be/.

ezimage are rendered thanks to: https://github.com/ezsystems/ezpublish-kernel/blob/master/eZ/Bundle/EzPublishCoreBundle/Resources/views/content_fields.html.twig#L416

But imageAlias.uri is already containing an absolute path because of: getBaseUrl() being used in: https://github.com/ezsystems/ezpublish-kernel/blob/master/eZ/Bundle/EzPublishCoreBundle/Imagine/IORepositoryResolver.php#L74

I suppose this is to be considered as an issue?

Does anyone see an easy workaround/fix to this?

Modified on Tuesday 06 January 2015 11:17:36 am by Patrick Allaert

Tuesday 06 January 2015 11:48:20 am

It looks like imagine kind of insists on returning an absolute path. I'm honestly not sure how it can be changed.

Why exactly doesn't it work in your case ?

Tuesday 06 January 2015 12:37:26 pm

The web servers are serving content via HTTP and in front of them, a dedicated Cisco Ace load balancer is in charge of (1) load balancing across servers, (2) encrypt the content between the load balancer and the browser via HTTPS.

If relative URLs were used exclusively, we wouldn't have the "mixed content" issue we are facing on https://www.lescheminsdeferengagent.be/.

Because of that, Internet Explorer users have a pop up warning them. See pictures at: http://msdn.microsoft.com/en-us/library/ee264315%28v=vs.85%29.aspx

Modified on Tuesday 06 January 2015 12:38:49 pm by Patrick Allaert

Tuesday 06 January 2015 1:20:25 pm

Okay, I think I got it.

The thing is that getBaseUrl() in the IORepositoryResolver relies on the original request's scheme. Since eZ itself uses unsecured HTTP, it generates images with HTTP, not HTTPS.

But this layer will only transform the URI if the one returned by IO starts with a /. This means you could do is use the URL decorator feature, and set the https URL directly here.

Monday 12 January 2015 10:03:22 am

Thanks Bertrand for your suggestion, however your suggestion does not work.

HTTPS is used to access the website from the outside of the network, HTTP is used to access the site internally and we are forced to have the SSL encryption set up at the RP/LB level.

For this reason, the only option that works is to generate relative URL's in all cases.

I have hacked IORepositoryResolver->resolve() to remove the call to $this->getBaseUrl(). Everything works correctly for now, but since I don't know the original reason. I cannot test efficiently why and when this was required. Something with LiipImagine?

An alternative and less intrusive solution would be decorate the "asset()" twig function so that it remove the scheme/host/port if it matches a defined one. But it seems there is no feature for decorating a function.

Wednesday 14 January 2015 11:34:02 am

Hi Patrick

I guess you're talking about absolute URLs, but not taking host into account. 

It's the Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface interface that "enforces" to return an absolute URL:

@return string The absolute URL of the cached image.

However, an URL with a leading slash is also considered as "absolute"... We're open to any pull-request for returning a URL beginning with a leading slash blunk.gif Emoticon.

Modified on Wednesday 14 January 2015 11:34:41 am by Jérôme Vieilledent

Saturday 21 October 2017 12:25:01 am

Patrick Did you find a clean way to make root relative URLs work?

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from