Jump to content

image httpUrl not woring in multi-instance


Gideon So
 Share

Recommended Posts

Hi,

I tried multi-instance and found that I cannot load image from other installation with $image->httpUrl.

<?php $site = new ProcessWire('/path/to/the/site/','url.of.the.site');  echo  $site->pages->get(pageid)->imagefield->httpUrl; ?>

This return nothing.

<?php $site = new ProcessWire('/path/to/the/site/','url.of.the.site');  echo  $site->pages->get(pageid)->imagefield->url; ?>

This only return the page path like site/assets/files/pageid/

I am using PW 3.0.33

Any ideas??

Gideon

Link to comment
Share on other sites

Is imagefield set to return a single image? This looks like you're accessing the data from a Pagefiles object. In that, case, this should work:

echo  $site->pages->get(pageid)->imagefield->first()->httpUrl;

 

  • Like 2
Link to comment
Share on other sites

On 7/10/2016 at 0:34 PM, BitPoet said:

Is imagefield set to return a single image? This looks like you're accessing the data from a Pagefiles object. In that, case, this should work:


echo  $site->pages->get(pageid)->imagefield->first()->httpUrl;

 

Hi Bitpoet,

Eventually you are right. In multi-instance environment, you need to call the first object even the limit of the image filed is set to 1.

Maybe this is a bug in multi-instance support.

 

Gideon

 

  • Like 1
Link to comment
Share on other sites

I think this might not be a bug, but even intended. It seems pages are returned without output formatting being enabled, which results in the behaviour you're seeing. Iirc bootstrapping processwire will do the same, but I'm not 100% certain on that. 

If you want your field settings to be respected call ->setOutputFormatting(true) on the page obj.

  • Like 2
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...