Download & Extend

Using ${field_term_image} in externalGraphic gives invalid image URL

Project:OpenLayers
Version:7.x-2.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

hi,

i want to put custom field value as externalgraphic path

${field_term_image} output: 'http://localhost/auto/sites/default/files/uploads/terms/directory/gazstation.png',

but in map is printed as:

<image id="OpenLayers.Geometry.Point_54" cx="389.9928530314937" cy="155.7978231292218" r="1" x="385" y="151" width="10" height="10" href="http://localhost/auto/%24%7Bfield_term_image%7D" style="opacity: 1" fill="#FFCC66" fill-opacity="0.5" stroke="#FF9933" stroke-opacity="1" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="none" cursor="pointer"/>

why?

Comments

#1

Not entirely sure how you set it up, but you may have to use the rendered version, and ensure you are using the URL formatter (assuming this is an imagefield).

#2

Hi! zzolo!

look, i'm using image_url_formatter module to output image field as path, so, in my view i have:

${title_rendered}
${title}
${latitude_rendered}
${latitude}
${longitude_rendered}
${longitude}
${field_term_image_rendered}
${field_term_image}
${name}

where

'field_term_image_rendered' => 'http://localhost/auto/sites/default/files/uploads/terms/directory/gazstation.png'.

now, i want to use this value in /admin/structure/openlayers/styles/default/edit "externalGraphic" field. so i put ${field_term_image} as value in it.

but after save, and open my map, the external graphic path is rendered as:

so u can see, the path to the image is broken.

P.D. sorry for my english

#3

Have you updated to latest version of 7.x-2.x?

#4

yes, last dev version from yesterday.

#5

#6

Status:active» fixed

#7

Status:fixed» closed (fixed)

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

#8

Title:Use ${field_term_image} in externalGraphic » Using ${field_term_image} in externalGraphic gives invalid image URL
Category:support request» bug report
Status:closed (fixed)» active

Hi,

I think I'm having the same problem. I have a taxonomy term with an image field. I set up the view appropriately, and the preview gives the token ${field_service_type_marker} which evaluates to the full path to the image. I try to use this in a custom style as the externalGraphic, and on the map the actual path used has the hostname doubled up (eg. http://example.com/http://example.com/sites/default/files/marker.png). The problem seems to originate in openlayers_render_style() where I think it tries to ensure there's a full path before doing the token substitution (resulting in http://example.com/${field_service_type_marker}. I'm new to OpenLayers, so could easily have missed something (I'm surprised nobody else seems to be whining!).

I've checked this both on the latest beta and latest from git.

TIA

#9

Category:bug report» support request

Hi @AndyF, are you still having this issue. I am not really sure what the issue is, we are just passing that value to file_create_url()

Do note that the fix described above is only in the dev version (7.x-2.x).

#10

I needed to use strategy.cluster so I ended up using a bit of JS to pass a context function for the parametrised values, effectively overriding the OpenLayers style settings, so I'm not seeing it as an issue anymore. But apparently I did check against the latest (I can't actually remember specifically now!). IIRC $style as passed to openlayers_render_style() hasn't had the token substitutions done. So if you try the following as a drush script:

module_load_include('inc', 'openlayers', 'includes/openlayers.render');
$style = array('externalGraphic' => '${field_service_type_marker}');
print_r(openlayers_render_style($style));

It shows externalGraphic as http://default/${field_service_type_marker} (just tested with 2.0-beta1). The problem is that $field_service_type_marker} is an absolute path itself, so that's where I think the double-up comes from. The way I got around it (before realising that clustering would screw everything up anyway!) was to use a computed field that returned the Drupal path (rather than absolute).

#11

Status:active» fixed

Hey @AndyF. This should fix it: http://drupalcode.org/project/openlayers.git/commit/2fe8a72

Basically the issue was that if the value was just ${value} then the Drupal url function would assume it was a relative path and then just stick the base path on it. But, if it is solely that sort of value, then we should just pass it through to OpenLayers.

I also added some more tests for this.

#12

Great stuff, thanks!

#13

Status:fixed» closed (fixed)

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

#14

Title:Using ${field_term_image} in externalGraphic gives invalid image URL» Get and Change ${count} value

in my view i have:
${count}
${name}
${field_location_rendered}
${field_location}
${title_rendered}
${title}
${#row_rendered}
${description}
I want to get value of ${count} and perform some calculations on it and again save ${count} in it. But cant sort out how it can b done. help needed.

#15

Status:closed (fixed)» active

in my view i have:
${count}
${name}
${field_location_rendered}
${field_location}
${title_rendered}
${title}
${#row_rendered}
${description}
I want to get value of ${count} and perform some calculations on it and again save ${count} in it. But cant sort out how it can b done. help needed.

#16

Title:Get and Change ${count} value» Using ${field_term_image} in externalGraphic gives invalid image URL
Category:support request» bug report
Status:active» closed (fixed)

@Mujtaba Ahmed I think that should be a new support request.

#17

In Views trying to change marker styles..

I have a field: ${field_allowed} which returns: "Y"
But I need it to return "Y.png" so externalGraphic will return website.com/Y.png as the marker style.
So I re-write the result.
Now ${field_allowed_rentered} returns: "Y.png" and ${field_allowed} returns "Y".
But externalGraphic still only returns "Y".

How can I set externalGraphic to return the field_allowed_rendered version? All the style setting allows me to select is field_allowed.