Hey! First thanks for this module, it's very great and I use it in different projects.

Now I think we also should render an entire entity instead of just showing an image with a caption. Means when using field_collection or entityreference module you can display them as a field slideshow with a specific view mode. So it's easier to control it with the field_ui or ds module.

What do you think?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

j-phat’s picture

subscribe

this would be an awesome addition to an already great module.
it would be nice to have, say, a caption field and a separate copyrights fields.

idflood’s picture

Status: Active » Needs review
FileSize
17.02 KB

I needed to have a slideshow on entity references for a project so I quickly made this patch. It's relatively basic now, but it should be enough for most cases. Let me know if something is missing or if you find any bugs.

idflood’s picture

Here is a cleaner patch with a different approach:
- Added some module_invoke_all inside the main module so that it can be extended
- Created a submodule field_slideshow_entity which implement these new hooks

This way the main module stays clean and it can be extended. When this get committed other things like media/file, jacarousel and field_collection support can be moved to submodules.

There is still one little detail that bug me with this patch. In template_preprocess_field_slideshow I needed to add this:

    // Entity reference has already a pseudo image generated, prevent it from being overriden
    $image = array('width' => 0, 'height' => 0);
    if (!isset($variables['items'][$num]['#entity_type'])) {
      // Generate the image html
      $image['path'] = $item['uri'];
      ...
    }

At least this should be $item["slide"] to be more coherent (entity, video, ...). But I believe there will be certainly a need for another custom hook there.

idflood’s picture

Looks like the patch in #3 needs a reroll.

markalosey’s picture

A reroll of this patch would really help me out...patch failed against the latest version of the module and dev

markalosey’s picture

Patch applies fine to 7.x-1.7 of the module....but I still can't figure out a way to get an entity reference to render as a slideshow.

TheJoker’s picture

I do not understand why this feature was not implemented by default. You can not create a full slider only on the text box.

As for the entity that I could not bring it into the caption.

idflood’s picture

Status: Needs review » Needs work
FileSize
14.14 KB

@TheJoker: Simply because at first field_slideshow was intended to be an image slideshow. More features are added with time but if this module doesn't suits your needs I would recommend to look at the views_slideshow module.

Here is a reroll of patch in #2 since the submodule experiment I made didn't had enough benefits.
I've added a function _field_slideshow_entityreference_field_type_settings since entityreference_field_type_settings is not in entityreference yet. @see #1580348: Make the formatters work with other reference fields

Other than that there is still some work to do, like fixing the height of the slideshow. For the height, the patch in the following issue may help a little: #1649624: Height Being Calculated Incorrectly

idflood’s picture

New patch with a little fix. There was a notice about $dimension being undefined so I made this little change:

    // Keeps biggest dimensions
    if (isset($dimensions)) {
      if ($dimensions['width'] > $variables['slides_max_width']) $variables['slides_max_width'] = $dimensions['width'];
      if ($dimensions['height'] > $variables['slides_max_height']) $variables['slides_max_height'] = $dimensions['height'];
    }
idflood’s picture

Reroll of patch in #9 based on the 2.x branch. I've fixed the $dimension with a cleaner method I hope.

idflood’s picture

So the issue seems to be about some css.

In cycle, there is a condition on this

var reshape = (opts.containerResize || opts.containerResizeHeight) && !$cont.innerHeight();

Who know why, but this set the container width to 0 and the slides then have a huge height.
In field_slideshow we let the default of containerResize to 1 so the container takes the height of the biggest slide.
http://jquery.malsup.com/cycle/options.html

One possible workaround with the following patch is to add this to the css:

.field-slideshow {
  width: 100% !important;
}

But this is not really clean I think (+ it could cause issue when updating). I will try to find another way of fixing this but if you have any idea let me know.

DrMicky’s picture

Hi

Love the module and timely issue resolution / patch ...

I tried to apply this patch but am using v1.81 which seems to have the changes already applied. So how do I actually get it to render the entire entity? What am I missing? I was expecting 'render entire entity' to become an option in the caption field or something like that.

Any help appreciated

yannickoo’s picture

Category: feature » support

BTW you could also use the Cycle module which provides this functionality :)

RaulMuroc’s picture

Same as #12, both topics:

  • Responsive layout: automatic size adapt to current image
  • Reference whole entity

Seems they should be solved in latest stable version but somehow I do not figure out to configure it. Perhaps an explanation in README.txt & module's page would be the best?

arbel’s picture

I'm stuck here as well, treid to apply the patch manually, but didn't quite take...

Idan

paulaulloa’s picture

I'm stuck here too, I tried to apply the patch manually, but didn't work

subspaceeddy’s picture

I rerolled and modified the patch against latest 7.x-1.x-dev branch if anyone needs it.

millionleaves’s picture

This patch has saved me a couple of times - thanks to all who have contributed.

Here are two scenarios where I've needed it:

  1. I have two node types, Event and Event Report.
    1. Each Event Report node references one Event node.
    2. The Event Report has a multi-image field.
    3. I want this image field to display as a slideshow on the referenced Event node.
    4. I'm using Views to create a block containing this image, and then placing it on the Event node with Panels
  2. I have Drupal Commerce.
    1. The Product entity has a multi-value image field.
    2. I want this image field to be a slideshow on the Product Display node that references the Product entity.

Without this patch, all images are displayed on the intended node at the same time instead of just the image currently active in the slideshow.

Not only that, but if I enable the Pager and specify the slideshow image as the pager, I get a pager block under each image.

This patch, therefore, rocks, in that it makes this module work correctly when Entity Reference is involved. It's a shame it's not been committed. Works for me!

John Pitcairn’s picture

So if the patch works and applies to current dev, what s stopping you all from tagging it RTBC? It won't be committed otherwise.