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:

  1. Do a clean install of Panopoly 1.41 with demo content.
  2. Log in as the administrator.
  3. Create a Content Page with an extremely long permalink.
  4. On the home page, click Customize this page.
  5. Click the Add button for a region.
  6. Click Add image.
  7. Click Browse and select an image from the library.
  8. Click the Search for existing content button for the Link field.
  9. Search for and select the page you created with the long permalink.
  10. Click Insert link.
  11. Note the link is inserted in the form node/NID.
  12. Click Save in the add content modal.
  13. Click Save at the bottom of the page.
  14. Hover over the linked image.
  15. Note the URL is truncated and ends with an ellipsis.
  16. Click the image to follow the link.
  17. 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'],
      );
    }
  }
}

Comments

cboyden created an issue. See original summary.

cboyden’s picture

Assigned: cboyden » Unassigned
Status: Active » Needs review
StatusFileSize
new639 bytes

This patch changes the code to use the real URL instead of the display URL.

dsnopek’s picture

Status: Needs review » Needs work

Unfortunately, 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..

dsnopek’s picture

StatusFileSize
new861 bytes

So, 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

dsnopek’s picture

Status: Needs work » Needs review
StatusFileSize
new11.09 KB

Here'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:

@@ -224,7 +225,7 @@ function panopoly_widgets_field_default_field_instances() {
         'title' => '',
       ),
       'display' => array(
-        'url_cutoff' => 80,
+        'url_cutoff' => '',
       ),
       'enable_tokens' => 0,
       'linkit' => array(
cboyden’s picture

Status: Needs review » Reviewed & tested by the community

This looks good, I've tested it on a Panopoly child distribution. URL is not truncated and query parameters are passed through OK.

  • dsnopek committed ff83098 on 7.x-1.x
    Update Panopoly Widgets for Issue #2832255 by dsnopek, cboyden: URLs...
dsnopek’s picture

Status: Reviewed & tested by the community » Fixed

Thanks! Committed

Status: Fixed » Closed (fixed)

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