Splitting this out from #1516446: Autocomplete for internal links for nivo slider link fields

Lengthy descriptions/captions lead to overflow in the document area see attached screen shot where I've highlighted the full text to clarify the overflow issue. I'm not sure if truncation and/or "read more" is a good solution here due to the various sizes of the markup the user may include. Also this is for the homepage editorial review by an actual person is likely the best solution.

From #1516446: Autocomplete for internal links for nivo slider link fields lightsurge indicates it would be nice to have a read more link if there is a nivo slider link provided. Right now if a nivo-slider link is present the image is clickable and takes you to the destination. It may not be clear to users that some slides are clickable while others may not be. Adding the read more link makes this more clear, but likely clutters up the slideshows.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

lightsurge’s picture

I think in terms of the overflow, it might work quite well to place a maximum string length on the Description field that the caption gets its content from, and disable/strip markup, essentially making it a plain text field... otherwise it could easily end up not very pretty.

Then as far as a read more link goes... A form_validate could be added in the slideshow feature to add a simple read more link to the slides with something like:

function julio_slideshow_media_edit_validate ($form, &$form_state) {
  if (!empty($form_state['values']['media_nivo_slider_image_link']['und'][0]['value'])) {

    // It doesn't matter that we're stripping markup from the media_description field, it can still be added to the caption
    $slide_link = l('<strong>Read more &raquo;</strong>', $form_state['values']['media_nivo_slider_image_link']['und'][0]['value'], array('html' => TRUE, 'attributes' => array('class' => array('slideshow-readmore'))));

    $slide_description = $form_state['values']['media_description']['und'][0]['value'] . $slide_link;

    // Append the read more link to the nivo slider caption
    $form_state['values']['media_nivo_slider_image_caption']['und'][0]['value'] = $slide_description;
  }
}

and css to position it:

a.slideshow-readmore {
  position: absolute;
  bottom: 0;
  right: 0;
  padding: 1.5em;
}
lightsurge’s picture

Status: Active » Needs review
FileSize
2.55 KB
341.26 KB

This patch

  • Puts in a slide heading taking the text from the media title
  • Strips all tags but links from the slide caption
  • Truncates the slide caption if larger than 330 characters (which seemed the best number to me from playing with the responsive sizing of the slideshow), allowing for link markup
  • Adds a read more link if there is a slide link present
  • Explains to the user that in slideshow mode, a truncated/filtered description will be used

This approach would also solve #1535568: Nowhere to set a slide heading

Here's a screenshot of the outcome with what would have been overflowing text and no read more link:

Titled, truncated slide with link

I sort of thought all of this might be better done in the slideshow feature, though, unless you're planning on having the ability to create a slideshow of all galleries rather than just the front page one?

penguininja’s picture

This looks great, though I haven't had a chance to test yet. Yes, ideally this would be in the slideshow feature. I'll check this out further as soon as I have time.

jgraham’s picture

Status: Needs review » Fixed

Committed 5da19d1, a modified version of the patch in 2

Thanks lightsurge! Patches really help get things moving along.

lightsurge’s picture

Does text_summary() allow for links etc being in there? Bit lazy to ask rather than to look, but that's great, wish I'd known about that function ;-)

jgraham’s picture

yeah, text_summary() you're pretty much at the whim of the filter format of the field. In this case filtered_html.

Status: Fixed » Closed (fixed)

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