Jump to content

Image URL With Web Service Module


jonathanp
 Share

Recommended Posts

Hi I am very very new to Process Wire, I have been playing around with the Web Service Module. However I would like to be able to get the url of the image suppled back through the json data. Currently it just returns the image name ? Is there a way to return this in the JSON data.

From the returned data (ajax call) I then create a page layout.

Any help or a prod in the right direction would be great.

Many thanks 

Link to comment
Share on other sites

Hi Jonathanp and welcome to PW!

I have only played with that module once so far, although I will be using it in an upcoming project fairly shortly. 

You should be able to build the URL yourself using the page id and image name, both from the json data?

Something like this - of course you'll need to define the $page_id and $image_name variables from the json data.

echo $config->urls->files . $page_id . $image_name;

Hope that helps.

If you haven't already seen it, take a look at the cheatsheet:

http://cheatsheet.processwire.com/

That will explain the $config->urls->files.

All uploads in PW are stored in this directory, with subdirectories named with the page ID.

  • Like 2
Link to comment
Share on other sites

  • 3 weeks later...
echo $config->urls->assets . $page_id . $image_name;

Hello Adrian,

I'm using Page Web Service module for passing data to android app. I'll have to pass full URL of the image. I just want to know how can I do that using your solution. I mean $config->urls->assets wont work outside of ProcessWire, so what can be a possible solution?

Thanks a lot.

Link to comment
Share on other sites

Well, this will get you the full url to an image if you know the page id and its name:

'http://' . $config->httpHost . $config->urls->files . $page_id . $image_name

Does the app know the url root to the page so you can build up the url to the image like that?

Presumably this will never change, so you can hardcode it as: http://www.mydomain.com/site/assets/files/ and then append the page id and the image name.

Maybe I am missing your point though.

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