jonathanp Posted January 13, 2014 Share Posted January 13, 2014 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 More sharing options...
adrian Posted January 13, 2014 Share Posted January 13, 2014 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. 2 Link to comment Share on other sites More sharing options...
jonathanp Posted January 13, 2014 Author Share Posted January 13, 2014 Thank you very much Adrian, now I understand the number in the url. I am actually using ember.js as a front end and retrieving the data via JSON. But that was a big help Many thanks 2 Link to comment Share on other sites More sharing options...
Vineet Sawant Posted January 31, 2014 Share Posted January 31, 2014 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 More sharing options...
adrian Posted January 31, 2014 Share Posted January 31, 2014 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. 1 Link to comment Share on other sites More sharing options...
Vineet Sawant Posted January 31, 2014 Share Posted January 31, 2014 Thanks Adrian, giving the hardcoded path does seem like a solution as domain will never change. Thanks again. Link to comment Share on other sites More sharing options...
Soma Posted January 31, 2014 Share Posted January 31, 2014 How about httpUrl ? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now