On our Drupal 7 site, we use the the services module to provide a feed for our internal news to pick up. With services, you create a view for all the data to provide. It is current giving the location of the original image for our images field (File: Path) that comes out http://oursite.com/sites/default/files/post.jpg. We want to provide a link to the styled image (already resized) that should look like https://oursite.com/sites/default/files/styles/downpage_art/public/field/image/solar_panels700x425.jpg?itok=P4VrgCIH. I don't see this as an option in the view we have for our feed.
2 Answers
I think the Image URL Formatter module will help.
Image URL formatter module offers 3 options that are not contained by views:
- support Image styles
- support multivalues, there is a "Multiple field settings" when image field is multivalue.
-
The module looked promising but the results came out as an empty array looking something like this: array ( 0 => stdClass::__set_state(array( 'url' => 'oursite.com/sites/default/files/post.jpg', 'caption' => 'Dick Post', 'mimetype' => 'image/jpeg', 'users_file_managed_mail' => '[email protected]', 'id' => '28815', 'alt' => 'post', 'title_text' => 'post', 'fid' => '28815', 'node_file_usage_nid' => '8900', 'Images' => array ( ), )),– shelaneCommented May 28, 2015 at 16:09
I'd recommend utilizing the Views Datasource module or the Services Views module. Both will allow you to set up a View to be consumed over a RESTful API. You can then use the View to easily select your image field(s), and the image style(s) to use.
Otherwise you'll need to implement hook_menu(), and create a custom item with a page_callback
. That page callback can then programmatically generate an image style URL, and output it with drupal_json_output.