Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
What was easy with Drupal 6 and Views is now kinda tricky in Drupal 7...
I would like to output the path to an imagestyle rendition of a file (EG: /files/styles/stylename/filename) that I could use in a javascript (EG: 'url' : '/files/styles/thumbnail/filename.jpg').
Sadly I have only minimal PHP skills ... if anyone could offer a solution (for Drupal 7), it would be greatly appreciated.
I initially raised an issue under Views and maintainer Dereline suggested CF was probably the solution.
Comments
Comment #1
Deciphered CreditAttribution: Deciphered commentedSorry for taking so long, but below is the code you want.
Single value formatter:
Multiple values formatter:
Comment #2
BarwonHack CreditAttribution: BarwonHack commentedYou are a legend!
Comment #4
Jerome F CreditAttribution: Jerome F commentedthank you - subscribing to keep it in mind
Comment #5
TimelessDomain CreditAttribution: TimelessDomain commentedThis is my 1st custom written php snippet. If you can improve upon it post.
This takes the image url & converts it into an embedded image with colorbox popup. I didn't know how to mod this so it works for multiple images,. If its possible to only have the first image show embedded & then the rest in colorbox, that would be great! Also - could someone could post how to link this to the node? thanks
Comment #6
Jerome F CreditAttribution: Jerome F commented@TimelessDomain you could also just just use the url formatter and take care of the rest in views with fields and rewrite rules. I tried to find a solution for the multiple images, but apparently colorbox needs to have all the actual images on the page to make the popup, and I couldn't find any other workaround, appart from using views slideshow in a colorbox trigger field: http://drupal.org/node/1161274#comment-4485714
Comment #7
Deciphered CreditAttribution: Deciphered commented@TimelessDomain
Quick coding standards rewrite:
Note: Untested, but should be right.
Comment #8
Lithops CreditAttribution: Lithops commentedHi,
I try this with 7.x-2.0-beta2 :
I have the right path, but without the filename at the end.
a little help?
Sorry for my english... ;)
Comment #9
Deciphered CreditAttribution: Deciphered commentedThe structure of the $variables object has changes in 7.x-2.x, it would now be: $variables['#items'][0]['uri']
Comment #10
sachbearbeiter CreditAttribution: sachbearbeiter commentedsubscribe
Comment #11
julien.reulos CreditAttribution: julien.reulos commentedI also work with the 7.x-2.x-dev version and a multiple link_field field type.
The code that is working for me (in this particular case, to render image links as thumbnails) is:
Comment #12
BarwonHack CreditAttribution: BarwonHack commented#8 and #9 no longer seem to work in Drupal 7.21
Any suggestions?
Comment #13
Summit CreditAttribution: Summit commentedHi, is #11 still valid? is it to be used with the link module?
EDIT I did a time back this: https://drupal.org/node/1397700#comment-5443478
Greetings, Martijn
Comment #14
Deciphered CreditAttribution: Deciphered commentedMost likely the reason they stopped working is due to the addition of itok for DDOS protection.
See https://api.drupal.org/comment/49773#comment-49773 for workaround.