To create a galleries using the Juicebox views style plugin, Juicebox Gallery format requires the field holding the image to be of type image, file or file ID.

There now exists a media management module named Scald where images are added to nodes by means of something called an "Atom Reference" field.

I want to use this field to be the source of the image when using the Juicebox views style plugin.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gisle created an issue. See original summary.

rjacobs’s picture

Hi.

I'm loosely familiar with Scald, though I have not used it on any official projects so the technical details are not all super-clear to me. There are a couple methods within the views style plugin that could probably be updated to support additional sources (assuming the direct source image URLs can be extracted from the rendered view object), but first I wonder if there are any existing alternatives. For example, is it possible to use some form of file relationship on your view to expose the file ids through an Atom Reference field? If so you might be able to setup a view based on Scald data/filters/context that still exposes a field that the Juicebox formatter already knows how to work with. I suppose this depends a bit on the level of views integration offered by Scald.

gisle’s picture

rjacobs, thanks for replying.

I am not too familiar with the Scald internals my self - but I'll look into the alternatives you suggest and report back here.

rjacobs’s picture

Status: Active » Postponed (maintainer needs more info)

Any updates regarding the points in #4? I'm just curious if we should keep this open.

gisle’s picture

The enclosed patch adds a Scald "Atom Reference" field to the type of fields that can be used as an image source to a Juicebox gallery.

Please consider adding it to the module.

gisle’s picture

Status: Postponed (maintainer needs more info) » Needs review

Changing status.

AsadKamil’s picture

Hi All,

The patch works fine ,thanks

root@asad-Vostro-3550:/var/www/html/git/juicebox# git apply -v juicebox-use_scald_atom_reference_field_as_image_source-2725279-5.patch 
Checking patch includes/juicebox.field.inc...
Applied patch includes/juicebox.field.inc cleanly.
root@asad-Vostro-3550:/var/www/html/git/juicebox# 
rjacobs’s picture

Thanks for sharing this.

A couple questions:

  • +    if (isset($item['sid'])) {
    +      // It is a scald atom. Convert to a conventional file item.
    

    I'm wondering if there is a more precise conditional check that could be used here? I'm not sure if any other modules could add an sid to any non-scald field items but it might be best not to take the risk. At a minimum I suppose we would need a module_exists('atom_reference') check.

  • +      $atom = scald_atom_load($item['sid']);
    +      $fobject = file_load($atom->base_id);
    +      $item =  (array) $fobject;
    

    Are there any common cases where we might have a broken atom link (as sid without a file object) that needs to be checked for? I don't know scald internals well enough, so it's very possible that this is all fine as-is, I just wanted to check. If we are always guaranteed a file object if there is an sid then could this be reduced to one line?:

    $item = (array) file_load(scald_atom_load($item['sid'])->base_id);
    
  • Does this all play nice with the existing title and caption options? How does scald store metadata like that?
  • Would anyone be willing to write a test case for this?
gisle’s picture

Sorry about taking so along before returning to this. An revised patch is attached.

I'm wondering if there is a more precise conditional check that could be used here? I'm not sure if any other modules could add an sid to any non-scald field items but it might be best not to take the risk. At a minimum I suppose we would need a module_exists('atom_reference') check.

I am not aware of any other module that add an sid to field-items, but I've added a module_exists('atom_reference') check. I can't think of anything else to check for.

Are there any common cases where we might have a broken atom link (as sid without a file object) that needs to be checked for? I don't know scald internals well enough, so it's very possible that this is all fine as-is, I just wanted to check. If we are always guaranteed a file object if there is an sid then could this be reduced to one line?

In scald a sid always comes with an associated file object. However, I also want to extract the image title and list of authors (if they exist) and add them to the item, so I need to have the atom object. I've reduced the rest to one line.

Please review.

Status: Needs review » Needs work
Neslee Canil Pinto’s picture

Status: Needs work » Closed (outdated)