I'm currently attempting to use Services Views on a view of nodes. I've added the content Author as a relationship, and I'm attempting to display that users photo. My issue is, when I ad that field to the view, it displayed in JSON with all of the HTML included. The same is true of a Video field. I'm wondering how I can go formatting these fields so I just get the raw URL of the image and or video. I've tried the "strip html" function in views, but it removes everything.

Comments

pau1_m’s picture

You could use Image URL Formatter module to output just the url of an image, otherwise you'll have to use services_raw output or write your own result in PHP with PHP Views module. There's also Custom Formatters module might help (I haven't tried it though).

dereckd’s picture

Thanks, thy both seem like great modules, but nothing seems to effect the output of the view. I'm thoroughly confused, it seems no matter what I do in the view, the services output is not formatted like I want it.

frankyn’s picture

StatusFileSize
new760 bytes

I added the strip_tags functionality to services_views with the following patch.

ygerasimov’s picture

Status: Active » Fixed

You can also use hook_services_views_execute_view_alter() to alter your results.

dereckd’s picture

This is great, however in my case I just need the src, which is inside the image tag, is there any possible workaround for that? Also, I'm just a little confused, where does the information from the database (the image src) get decorated with all of the HTML. Since this is a service view, would it make sense display the raw url directly?

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

manicato’s picture

Status: Closed (fixed) » Active

Same problem than #5. The patch doesn't fix the issue

dippers’s picture

@manicato look at the field formatters suggested in #1922620: How do I alter field output before it goes to the service.

tripper54’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new762 bytes

I have re-rolled #3 for latest dev. I know it doesn't address the OP's issue, but it fixes a bug of the UI not working as expected.

For rendering images as URLs instead of img tags, I use https://www.drupal.org/project/image_url_formatter with great success, for services views and elsewhere.

tripper54’s picture

StatusFileSize
new762 bytes

...and here is the patch correctly named ;)

visabhishek’s picture

Status: Needs review » Reviewed & tested by the community

Hi,
Patch looks good to me, and working fine to remove HTML from certain fields.

Thanks @tripper54 for this patch.

thedut’s picture

#10 works for me, thanks

generalredneck’s picture

Status: Reviewed & tested by the community » Closed (duplicate)

Looks like this was already committed in #1917032: Search API with Services Views