The ability to link an Image widget was introduced in Panopoly 1.38 (see #2013965: ability to link images placed with image widget). There's been a bug in this since introduction. When you have a URL that ends up being longer than 80 characters, the href attribute of the a tag that's generated when the widget is rendered is truncated to 80 characters plus an ellipsis.
To reproduce:
- Do a clean install of Panopoly 1.41 with demo content.
- Log in as the administrator.
- Create a Content Page with an extremely long permalink.
- On the home page, click Customize this page.
- Click the Add button for a region.
- Click Add image.
- Click Browse and select an image from the library.
- Click the Search for existing content button for the Link field.
- Search for and select the page you created with the long permalink.
- Click Insert link.
- Note the link is inserted in the form node/NID.
- Click Save in the add content modal.
- Click Save at the bottom of the page.
- Hover over the linked image.
- Note the URL is truncated and ends with an ellipsis.
- Click the image to follow the link.
- Note you see a Page Not Found error.
This is probably because the display_url is being output instead of the url:
/**
* Implements hook_fieldable_panels_pane_view().
*/
function panopoly_widgets_fieldable_panels_pane_view($entity, $view_mode, $langcode) {
if ($entity->bundle == 'image') {
// Render the image in a link if one is given.
if (!empty($entity->field_basic_image_link[LANGUAGE_NONE][0]['url'])) {
$entity->content['field_basic_image_image'][0]['#path'] = array(
'path' => $entity->field_basic_image_link[LANGUAGE_NONE][0]['display_url'],
);
}
}
}
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | panopoly_widgets-image-url-truncated-2832255-5.patch | 11.09 KB | dsnopek |
Comments
Comment #2
cboyden commentedThis patch changes the code to use the real URL instead of the display URL.
Comment #3
dsnopekUnfortunately, this has some other side effects: it removes any GET arguments from the URL. We need to find a property or way of generating the full URL, but without truncating it..
Comment #4
dsnopekSo, I was originally trying to regenerate the URL (patch is attached) but I realized the fix is much simpler! We can just disable truncating the URL on the Link field settings. Patch for that coming soon
Comment #5
dsnopekHere's the new patch! It's bigger than necessary because of changes to Features output since the last time we updated the feature, but the key change is:
Comment #6
cboyden commentedThis looks good, I've tested it on a Panopoly child distribution. URL is not truncated and query parameters are passed through OK.
Comment #8
dsnopekThanks! Committed