I have a slideshow of images, and I want those images to link back to the node that I pulled them from. I have appropriately set the image field that I am using to output the field as a link, and using replacement patterns, I put in the correct path. But the images still do not output as links. In Views, I tried the same method to get the images to output as links using various other formats besides Views Slideshow: Galleria, and it worked with those, which leads me to believe this is an issue with Views Slideshow: Galleria. I have made a patch that I think fixes the problem, which will be posted in a few minutes.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

madelineheller’s picture

Status: Active » Needs review
FileSize
1.26 KB

Patch attached, feedback would be appreciated. Thanks!

davidwatson’s picture

Tested this on our own install profile; by adding it through longdesc Galleria itself will pick up the link. Another set of eyes for RTBC?

sgabe’s picture

I think this should be done manually, since Galleria can handle numerous additional attributes we can't create an output that will fit for every case. E.g the wrapper <a> tag around the <img> is used to link to the original image when you want separate thumbnails. I think the current behavior is good for most cases. You can turn off the "Strip images" option and generate the needed output manually.

Leeteq’s picture

Version: 7.x-3.0 » 7.x-3.x-dev
Category: bug » task
Priority: Normal » Major
Status: Needs review » Needs work

@sgabe/#3: If I understand your reply correctly, you are saying that this is already possible if one knows how to do it.
For whom is it supposedly "possible" with the current module version? (how deep insight is needed; only for developers, not for admins/users?)

In this issue, we have a good example: a person capable of identifying and working out a suggestion to "solving" a problem programatically, seems to have missed that it might already be possible. Judging from the various issue queues I have browsed through, it seems that many people dont know how to to this, and also perhaps falsely assume that it is simply not possible in the current module version(s).

So, should this "bug" be turned into a task for improving the docs, or perhaps even a part of the UI?
(even just improving the descriptive text for some fields?)

How about writing a very quick/short (precise) "how-to" list here in this issue so that people can test it and report back if it contains enough information to understand how to get this working? Then we can prepare it for the Readme.txt etc. from there, after the how-to is clear.

(in case I am mistaken here; what do you mean by "current behaviour is good for most cases"? Does it not mean that it is actually possible to link to the content through configuring the module, if only the how-to is understood?)

davidwatson’s picture

Priority: Major » Normal

Indeed - if there is a better way of doing this, it isn't immediately intuitive (we've configured the Views Slideshow to retain original markup, with no success). If you have any specific insights on how to go about it, we'd be happy to update the documentation from there.

sgabe’s picture

You can use custom formatters to create the needed output. For example install the Custom Formatters module and override the image formatter example like the following:

$settings = $variables['#display']['settings'];

$uri = entity_uri($variables['#obj_type'], $variables['#object']);
$link = url($uri['path'], $uri['options']);

$element = array();
foreach ($variables['#items'] as $delta => $item) {
  $item['attributes'] = array('longdesc' => $link);
  $element[$delta] = array(
    '#theme' => 'image_formatter', 
    '#item' => $item,
  );
}

return $element;

This adds the longdesc attribute to the image tag containing the path to the node, so the image will link to the node in Galleria. Don't forget to disable the Strip images option.

Because of the flexibility of Galleria and Drupal I think it is pointless to hardcode these.

davidwatson’s picture

Status: Needs work » Needs review

I see - was hoping to not have to override formatters like that, which we could do anyway without the bloat of another module. It seems strange not to support this functionality when Galleria does so out of the box (as do comparable modules), though of course the decision to add or not is your prerogative. :]

Setting back to CNR, as the functionality is indeed missing and both the patch and the idea could stand to be vetted. Feel free to Won't Fix if you feel this is out of scope.

sgabe’s picture

Category: task » feature
Status: Needs review » Needs work

I am open to add some field formatters if someone comes along with a patch, but the one in #1 won't be committed. I leave this open for now in case somebody wants to pick it up. I don't know when will I be able to work on this.

aendra’s picture

Wish I would have found this issue before writing a really hacky template and wasted the last hour or so just trying to find Galleria's stupid longdesc attribute. Durr, a display formatter, that makes sense now...

You completely lose the "front page slideshow" usage case (Which, in my experience, is by far the most frequent use of Javascript-based slideshows) by not being able to link to arbitrary content. And telling users to write their own display formatter is really weak. Put me down as +1 for wanting this as a feature.

Chasen’s picture

@aendrew Completely agree.

+1 subscribing

davidwatson’s picture

Circling back to this. May I ask what it is about the approach in #1 that makes it unsuitable? Perhaps we could use that as a starting point?

sgabe’s picture

See #3.

aendra’s picture

@sgabe -- Your logic is that "If people want this functionality, they should write their own display formatter or custom template or whatever."

However, it has been asked for by several people and there is a very *valid* and *common* usage case for this (Front page content slideshows). Is it really so difficult to add an option somewhere that changes the default behaviour to what we're asking for?

Also, quote:

"...since Galleria can handle numerous additional attributes we can't create an output that will fit for every case."

This doesn't make sense; the request isn't to expose all of Galleria's options to Views -- it's to provide for a very basic and simple use case...

sgabe’s picture

@aendrew: I don't want to repeat myself, see #8.

aendra’s picture

@sgabe -- Ah, apologies! I didn't see that. I might have a go at that if I get bored this weekend.

filijonka’s picture

Status: Needs work » Closed (works as designed)

hi

This could be done with template_preprocess_view and rewrite the output for the image to include data-link which would point to the node url.

You should probably add the nid to the view so you can load it, think you also need to add in advance the option of strip images.

aendra’s picture

Status: Closed (works as designed) » Postponed

@filijonka -- Just because you can accomplish something by hooking into template_preprocess_view and writing your own code to do so, doesn't mean that goal shouldn't be made as a feature suggestion.

The authors seem unwilling to write it into the code themselves; I'll set status to "postponed" to allow for the possibility of somebody writing a patch that allows this.

aendra’s picture

Status: Postponed » Needs work

Err, rather, as a patch has been already attempted, setting to "Needs Work" as per #8.

filijonka’s picture

@aendrew Since @sgabe been very clear that this patch won't be included and it's his module it really doesn't matter there is a patch or not.

So I provided a suggestion justlike @sgabe did how this could be done.

aendra’s picture

@filijonka -- Apologies if I came across harsh there; I think your idea's great and at the moment it's one of the better ways to make this module do what this issue is asking for. Moreover, I was just giving my rationale for reverting your status to the one the maintainer set in #8.

Quote:

I am open to add some field formatters if someone comes along with a patch, but the one in #1 won't be committed. I leave this open for now in case somebody wants to pick it up. I don't know when will I be able to work on this.

It's an easy enough thing that I might write one -- @sgabe, could you at least outline why your think the existing patch isn't good? You just told @davidwatson that he should look at #3, which is, I quote:

I think this should be done manually, since Galleria can handle numerous additional attributes we can't create an output that will fit for every case. E.g the wrapper <a> tag around the <img> is used to link to the original image when you want separate thumbnails. I think the current behavior is good for most cases. You can turn off the "Strip images" option and generate the needed output manually.

I'm not sure I understand -- the patch is no good because you think people should do it manually? Then what are you actually open to as per #8?

sgabe’s picture

Let me rephrase my comment: I will support a patch that actually improves the module by adding a needed functionality. The attached patch modifies the code in a way that does not improves the module, but removes funcionality, exchanges a feature with another one.

aendra’s picture

@sgabe -- Thanks! That's helpful!

filijonka’s picture

Hi

@aendrew I stand corrected and my apologies I must have misunderstood some.

If I understand this problem correctly what people are asking for is away to manipulate the imageobject that galleria is using.

if galleria gets an html <img src="image.jpg"> this is made to a imageobject as

{
    thumb: 'image.jpg',
    image: 'image.jpg',
    big: 'image.jpg',
    original: [IMG element]
}

So the html for an image decides how the gallery is build, there are several additions you can make like, decide which image you want for thumbs,
<a href="image.jpg"><img src="thumb.jpg"></a>

results in an imageobject

{
    thumb: 'thumb.jpg',
    image: 'image.jpg',
    big: 'image.jpg',
    original: [IMG element]
}

read more at Galleria.io

ok so an addition for improving the module would for an example be adding a Field plugin where the user can decide which field is going to define a object data.

Take a look at the module Views Galleriffic that are doing something similar but not using Galleria but a field plugin.

/Peter

mmeldrem’s picture

@sgabe Thank you very much. #6 worked for me to link to node. I was even able to add title and alt attributes for captions using this method.

However, in the image field settings in the view, it gives me source image style and destination image style, but neither of these seem to pass through to the galleria.

Do you know how I can change the image formatter to pass these values in?

I am even willing to hard-code the specific image style into the formatter if need be.

Thanks.

elBradford’s picture

I was able to do this using the module and custom text to build the proper link. I have a bunch of fields, including a thumbnail (and images are output using the url formatter module previously mentioned), and all of them are hidden and used as replacement patterns in the global custom text field, which I entered as

<a href="[field_slide_image]"><img src="[field_slide_image_1]" data-title="[title]" data-description="[field_slide_text]" data-link="[field_slide_destination]"></a>

This worked for me. I'm not going to use galleria because it doesn't appear to be adaptive, but this worked pretty well to get everything into a galleria format.