Problem/Motivation

When displaying images in a Colorbox via Media, Picture doesn't provide options to set the gallery context and it's not possible to get galleries working.

Using the default Colorbox display in Manage File Display allows selecting gallery grouping options:

  • Per post gallery
  • Per page gallery
  • Per field in post gallery
  • Per field in page gallery
  • Custom
  • No gallery

These options aren't available in the Picture display that allows display port.

Using Picture 7.x-1.2+6-dev

Proposed resolution

Perhaps a custom Picture Colorbox is needed to enable these extra settings and enable the use of the gallery.

  • Create a new formatter that combines the fields from Picture and Colorbox
  • Implement necessary JS changes for the script to handle all the fields set above

I've implemented a mini-module that adds a Picture Colorbox formatter. I've gotten the backend of the formatter working by merging code from Picture and Colorbox to have settings from both.

I'm a bit stuck on the implementation of the theme hooks to implement the frontend part of it so it doesn't currently render correctly.

Comments

Nodz’s picture

Issue summary: View changes
StatusFileSize
new5.11 KB
xaa’s picture

hi, any progress on this issue ?
Nodz, your module (thanks) can be considered as stable?

khaled.zaidan’s picture

Wow, Nodz, this is a really nice effort (for an important issue!)

What I'm wondering about is why should this be implemented in a separate module?
The colorbox intergration that is already in the picture module, is incomplete, and the ability to group pictures in a gallery definitely needs to be added.

Plus, this would save some time re-implementing the theming of the field!

I'll work on a patch for the module for this... hopefully gets reviewed/committed to for the next release!

khaled.zaidan’s picture

Assigned: Unassigned » khaled.zaidan

Assigning to myself :)

khaled.zaidan’s picture

Status: Active » Needs review
StatusFileSize
new12.35 KB

Alright, I just created a patch against the latest dev version.

It now allows settings for the Picture field formatter same as the module colorbox did. So we can finally use the picture with colorbox and still have the galleries functionality from colorbox :)

Can the module maintainers please have a look?

Cheers,
Khaled

timlie’s picture

#5 Does not completely work for me.
When I set the settings in a view no matter what option I choose for grouping I never can click through the gallery. The title of the gallery is added on the bottom of every picture, so this does work.

Any idea what goes wrong?

attiks’s picture

This looks good, not completely tested, only some remarks on coding standard.

  1. +++ b/picture.module
    @@ -402,10 +415,24 @@ function picture_field_formatter_settings_form($field, $instance, $view_mode, $f
    +  /* Settings for the colorbox option*/
    

    use // for the comment

  2. +++ b/picture.module
    @@ -415,6 +442,91 @@ function picture_field_formatter_settings_form($field, $instance, $view_mode, $f
    +    'auto' =>  t('Automatic'),
    

    2 spaces, should be 1

  3. +++ b/picture.module
    @@ -474,6 +586,35 @@ function picture_field_formatter_settings_summary($field, $instance, $view_mode)
    +  // Dsplay the settings for the colorbox if chosen
    

    missing a dot at the end.

  4. +++ b/picture.module
    @@ -569,6 +710,76 @@ function picture_field_formatter_view($entity_type, $entity, $field, $instance,
    +      // Add the group ID
    

    missing a dot.

  5. +++ b/picture.module
    @@ -569,6 +710,76 @@ function picture_field_formatter_view($entity_type, $entity, $field, $instance,
    +      // Add the caption
    

    missing a dot.

  6. +++ b/picture.module
    @@ -569,6 +710,76 @@ function picture_field_formatter_view($entity_type, $entity, $field, $instance,
    +      // Shorten the caption for the example styles or when caption shortening is active.
    

    comment is too long.

timlie’s picture

Is there any progress on this issue?
For me this patch did not work completely and I can't figure out in the code why it does not...

Thanks!

espurnes’s picture

Hi I've not tried the patch yet but I have another solution to it. It's much better to have the module working properly than my approach but meanwhile it can be useful.

The idea is to add the rel attribute that groups the images using javascript. I posted the steps in this other post.

You can add the rel attribute with this line of code:
$('a.colorbox-inline').attr('rel', 'myImgGroup');
I've used a behaviour to place this line.

For better results I used a custom module to get the nid.

function MYMODULE_node_view($node, $view_mode, $langcode) {
  if ($view_mode == 'full') {
    $setting = array('MYMODULE' => array('currentNid' => $node->nid));
    drupal_add_js($setting, 'setting');
  }
}

Then I can use the nid in the behaviour

Drupal.behaviors.MYTHEMEColorbox = {
  //This code add a rel attribute to colorbox-inline links to activate the prev next functionality in colorbox
    attach: function (context, settings) {
      var curr_nid = settings.nid.currentNid;
      $('a.colorbox-inline').attr('rel', 'group' + curr_nid);
    }
  };

I hope it helps

attiks’s picture

Status: Needs review » Needs work
das-peter’s picture

Status: Needs work » Needs review
StatusFileSize
new12.94 KB
new4.39 KB

Here's a new version that addresses the things mentioned in #7 as well as some issues related to the file entity integration (see the interdiff).

das-peter’s picture

Assigned: khaled.zaidan » Unassigned
StatusFileSize
new13.15 KB
new3.86 KB

Another slight change to ensure the form element states work in the file entity file display formatter settings form too.

das-peter’s picture

StatusFileSize
new13.27 KB
new1.02 KB

Darn, forgot a form element state.

attiks’s picture

Assigned: Unassigned » jelle_s

  • Commit 495765b on 7.x-1.x authored by das-peter, committed by Jelle_S:
    Issue #2138273 by das-peter, khaled.zaidan | Nodz: Added Picture...
jelle_s’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Assigned: jelle_s » Unassigned
Status: Needs review » Needs work

Fixed in latest dev. Thank you for the patch!

Any chance you can write a similar patch for 2.x?

das-peter’s picture

Status: Needs work » Needs review
StatusFileSize
new13.23 KB

Unfortunately I don't have a test-env ready for 7.x-2.x.
However, I've manually re-rolled the patch to apply to 7.x-2.x and as far as I've seen it should / could work ;)

  • Commit 69e3aff on 7.x-2.x authored by das-peter, committed by Jelle_S:
    Issue #2138273 by das-peter, khaled.zaidan | Nodz: Added Picture...
jelle_s’s picture

Brilliant! Just tested it and it works. Committed to latest dev.

I'll write the update functions for both 1.x and 2.x

  • Commit da93b44 on 7.x-2.x by Jelle_S:
    Issue #2138273 by das-peter, khaled.zaidan | Nodz: Added Picture...
jelle_s’s picture

Status: Needs review » Fixed

Fixed in 1.x and 2.x. Thanks for all the hard work!

  • Commit 164f8fd on 7.x-1.x by Jelle_S:
    Issue #2138273 by das-peter, khaled.zaidan | Nodz: Added Picture...
das-peter’s picture

@Jelle_S Fantastic! Thank you very very much!!

Status: Fixed » Closed (fixed)

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

xaa’s picture

could you let me know if this patch has been committed to the 1.5 version, please ?