First of all: Thank you for creating this module! I have tried to use it in connection with VIEWS and while the ALT text is being displayed the link function is not working. The view simply displays the image and alt tags. Am I missing something or is this something that is a future feature?
Thank you for your time.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | 20130305ILF_views_support_rev1.jpg | 159.55 KB | dydave |
| #1 | 20130305ILF_views_support-exclude-link-field_rev1.jpg | 142.95 KB | dydave |
| #1 | 20130305ILF_views_support-link-image-field-settings_rev1.jpg | 162.49 KB | dydave |
Comments
Comment #1
dydave commentedThanks very much for posting this issue and your feedback on the module.
We always appreciate to receive a good feedback and encouragements.
Alright, so let's try investigating further what happens with this formatter in Views:
1 - Rendered entity views: [OK: everything should be fine]
In any Views, in the section FORMAT, if any formatting type is selected to render entities with a particular view mode, for example:
So basically, any view that would not allow selecting specific fields, then in this case, there shouldn't be any problem.
I have already tested and it seems to work as expected, which is easy to understand:
Basically, since each node (or whatever other entity) is rendered as a whole with node_view (or hook_entity_view), I would assume, the image_link_formatter is able to find attached link fields to the rendered entity.
So, no problems in this case.
As a side note, the rendered entity and display output would have to be confured in Manage Display (and NOT in Views) for the corresponding Node (or entity), Content Type (or bundle) and the corresponding View Mode (for example, teaser, full content or any other view modes).
2 - Field views: [Not OK: there seems to be issues here.... but there is a work-around]
So it seems the problems would only happen when a Views FORMAT for fields is selected, so for example:
When adding an image as a field to the views, in the settings, it is possible to select the Image Link Formatter, however, the Link to dropdown in the image formatter settings in views, will not allow selection of the expected custom link.
To clarify visually, I have attached a quick screenshot: 20130305ILF_views_support_rev1.jpg.
on which I have detailed the types of views for which this issue would occur and the problem with the Image formatter settings.
The main reason for that (as shown in the screenshot) seems to be caused by the absence of attached entity or bundle, in this case, for the particular image field instance.
In other words, Views doesn't differentiate for which node (or other entities) and content type (or bundles), this field should be rendered and therefore, image_link_formatter fails in finding Link fields that would be attached to the listed objects.
This is very understandable, given the level of abstraction taken by views, when displaying fields.
Another way to put it is that in this particular case, Image Link Formatter would have the exact same behavior as the Core Image formatter.
(With fields display, for an image, selecting Image or Image Link Formatter, would be the same)
However, Views already provides an alternate solution for that through REWRITE RESULTS in the fields views display configuration settings:
1 - Add the custom Link field that should contain the URL to which the image should be linked:
See attached screenshot: 20130305ILF_views_support-exclude-link-field_rev1.jpg.
Select to exclude this field from display and also format it as a plain text full URL (later used to be inserted in a custom link).
Make sure this field is added or displayed before the Image field around which you would like it to be wrapped up.
(Rearrange the order of the Fields in the Views)
2 - In the Image field views display configuration settings:
See attached screenshot: 20130305ILF_views_support-link-image-field-settings_rev1.jpg.
Select to REWRITE RESULTS, in particular, select to Output this field as a link.
This should pop-out a section with more settings, in particular Link path in which you should be able to enter Replacement patterns, or add any other customizations to the link.
Once again, I have tested this method (to make the screenshots, at least) and everything seems to work as expected.
To sum this up:
1 - When using Rendered entities, there is no problem.
2 - When using Fields, there is another practical alternate solution and actually the Image Link Formatter simply behaves like the Core Image formatter (we could say, it degrades gracefully: no bug, it simply doesn't allow user to select a custom link).
Since we would be able to find a proper way to achieve the same objectives with Views, then perhaps there wouldn't be much Views support integration to add to the module.
Therefore, I allowed myself to change this ticket to support request, with a status needs review as an attempt to get more feedback from you or any other users.
I would greatly appreciate to have your feedback, questions, comments, suggestions, recommendations, objections or concerns on any aspects mentioned in my reply or this ticket in general, I would surely be glad to provide more information or explain in more details.
I sincerely hope my answer will help resolving this issue and help you find a proper way to achieve what you initially wanted to do with the formatter.
Feel free to let me know if you would have any more questions, comments or issues on this particular ticket, I would certainly be happy to take a closer look.
Any further comments, feedback, testing, reviews or reporting would be highly appreciated.
Once again, thank you very much creact for your interest, support for this module and reporting this particular issue.
Thanks to all in advance, for your comments, feedback and replies.
Cheers!
Comment #2
dydave commentedThis support request with a status of needs review has been awaiting response from the author or any other user for more than two weeks (See #1, last updated: March 5, 2013 at 10:40am):
Changing status to fixed for now.
Feel free to change the status again to needs work or active if you still have any problem with this particular issue, I would surely try answering as soon as possible.
Thanks in advance for all your comments, feedback and testing.
Cheers!
Comment #4
srhom commentedThank you for your detailed explanation. It really helps. I have tried both of the solutions that you described above, and they worked as expected. One issue that I could not find a solution for was the instance of opening a link into a new (_blank) window.
I am attaching links to images in a Flexslider slideshow. Some of these links need to be opened into a new window.
This function works fine when I am displaying the image slides as complete nodes (full content), but then I also have the labels and other fields (such as display order) displaying in the slideshow.
Changing to the Fields view and attaching the link to the image by using a replacement pattern disables the target option that I selected in the Link field.
Any workarounds for this situation?
I had thought of using CSS to hide the other node elements, but was hoping for a better solution than that.
Comment #5
dydave commentedHi guys,
Thanks a lot for your great follow-up, feedback on this issue and the module in general.
It seems this issue has raised quite a few requests most of which would be related with Views and ctools/Views integrated modules, such as Flex slider or Panelizer (for example, see: #2017407: Error in formatter style form).
Thanks to @gaofengzzz's great work and insight, it seems there would be an appropriate solution to solve this issue to allow rendering of the Image Link Formatter in Views Fields.
To sum up the problem and solution:
The problem is that in a views for a particular entity (for example, node), if Fields are displayed, the formatter has no way to know to which bundle (for node it would be content type) the selected Image field would be attached:
Indeed, the same Image field could have two instances on two different content types (bundles) with potentially different Link fields.
Since in views, it would be possible to display both content types, in the same view, in this case, which link should be loaded to be wrapped around the image?
Solution: Let the user decide.
So basically, the patch/code introduces a special case in the
function image_link_formatter_image_field_link_typesto add more Link fields to be listed in the formatter settings dropdown (Link image to).All the Link fields from all the bundles to which the Image field is attached should be listed.
For example, if an Image field is attached to the two content types: CT1 and CT2, with two Link fields LF1 and LF2, the two Link fields would be displayed in the dropdown allowing users to select in Views with which field the image should be linked and from which bundle it should come from.
This feature also does no harm, since if a link field of a different bundle is selected, it would not display and wouldn't break or render the system buggy/unstable.
Lastly, this would seem like a very appropriate solution given that in Views, pretty much everything needs to be configured (solution in the "views way").
In any case, I went ahead and got this committed against the 7.x-1.x branch at d93ba6b.
Feel free to re-open this issue, or post a new ticket, at any time if you have any further objections or still encounter any issues with this feature request or the related commit d93ba6b (we would surely be happy to hear your feedback).
Please let me know if you would have any further comments, feedback, questions, issues, objections, suggestions or concerns on any aspects of this ticket in general, I would be glad to provide more information or explain in more details.
Special thanks to @gaofengzzz for the great work, idea and suggestion to come up with a nice fix for this issue.
Thanks again to everyone for your help, reviews, feedback and comments on this issue.
Cheers!
Comment #6
voodoodan245730 commentedHi and thank you for your amazing module and post!
I am using flexslider to provide a slideshow on my homepage.
Problem is, when using method "2 - Field views" the images are duplicated and views renders the flexslider like so :
Configuration :
Image 1 has Link 1
Image 2 has link 2
Views renders it as :
Image 1 and image 2 have link 1
Image 1 and image 2 have link 2
Anyone find how to fix this???
Thanks!
Comment #7
gregoryshearer commentedI am having some real issues like I have never seen in 8 years of using Drupal. The only reason I tried to use this module is I want the user to be able to select whether they want the link to open in a new window or not as they create the content. This all works great when looking at the node as a regular page. I can set the formatter and associate the image with the link and it will open in a new window (or not) based on the setting on the link field.
But I am trying to use this module with Views jCarousel in Drupal 7. I have the View set to display Fields. I am outputting the Image field and the Link field. The formatter is set up correctly. Now if I set the Link field for a particular node to open in a new window, it works. Both the Image and the Link open in a new window. BUT if I then go and switch the link field for that node back to NOT open in a new window, in the View the Image STILL opens in a new window. The Link field, from the same node, displayed in the View directly below the image, does NOT open in a new window. It is as if the Image get "stuck" opening in a new window.
I have flushed caches repeatedly and no change. It still pops open in a new windows. I tried in an entirely separate browser (IE, which I typical never use) to see if something was cached with the browser, but it still happens. I give up at this point.