4

I have a user that I want to expose to services. Using Services Views. I'm using fields as the format, and adding the "photo" field to my display. My issue is that when I view the service (as JSON). I get all the HTML as well as th image URL, for instance

users_node_picture: "<img typeof="foaf:Image" src="http://mysite.com/sites/mysite.com/files/styles/thumbnail/public/pictures/picture-36.png" alt="" />",

I need just the url, I've tried the following with no luck.

  1. Strip HTML (removes everything)
  2. Rewrite output (same result)
  3. Row theming (does not effect the services result, only the html page)
  4. Installed Views PHP (by returning the row, I simply get the field id)

Is there any other way to effect the output of this field before it is outputed by Services Views? I thought perhaps I could do something with template_preprocess, but I'm not really sure how I would go about doing it.

  • Have you found a solution to this issue? – Bhuvana Mar 22 '16 at 10:57
5

You can do it using relationships! Under Advanced, add the relationship File Usage: File. Then go add a new field, and you'll see File: Path.

Alternatively, you could use the Image URL Formatter module. This allows you to print an image as a URL. Then in the field settings in Views select this under 'Format' for the image field. The module has some features that would be harder to achieve with the relationship, but for most cases the relationship should work.

  • 1
    Good call I would suggest using the Image URL Formatter module, its always a standard use on our dev team – chadpeppers Feb 25 '13 at 19:17
0
  • Create a file called field.tpl.php in your theme folder
  • In this new file, add the code detailed here:
  • Edit the code to suit how you want it show, for example if you want the raw output with no Divs etc
$item) : ?> type); $item=$items[0]; //Just display the first date $display=field_get_display($instance, 'default', $node); $display['settings']['format_type']='short'; //Alter the display $vars['dates'] =date_formatter_process('date_default', 'node', $node, $field, $instance, $langcode, $item, $display); $output=theme('date_display_combination', $vars); ?>
  • Please see number 3, field templates do not seem to effect the output of the field to services, I'm not exactly sure how services views works, but apparently it is pre - template. – user379468 Feb 20 '13 at 14:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.