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.
Is there a way to add images to checkboxes/radio buttons? So the image shows instead of the text.
Thanks!
Comments
Comment #1
asak CreditAttribution: asak commentedI've experimented with this but didn't get anywhere...
Very interested in this option...
Comment #2
asak CreditAttribution: asak commentedGot it. simple actually.
in Allowed Values, use the following format:
no|
<img src="/what/ever/none.png" alt="No">
yes|
<img src="/what/ever/yes.png" alt="Yes">
And it works.
Comment #3
bsherwood CreditAttribution: bsherwood commentedThat does work, but it messes up the label. So instead of having a human readable label it shows the tag.
Any other ideas about this?
Comment #4
bsherwood CreditAttribution: bsherwood commentedRe-opening because method above leads to the issue being fixed in a haphazard kind of way.
Does anyone else have any suggestions to get images to show on nodes when a select list option is selected?
Thanks
Comment #5
asak CreditAttribution: asak commentedWell... you're right.
This does not work for select lists. It does for check-boxes and radio-buttons.
If you're trying to show images instead of the labels, when viewing nodes, the only way i've managed is by using the conditional fields module. Create a conditional check-boxes field, and set it to display only when specific select list options have been chosen. the default value of the field should be set to the image you want to show.
Comment #6
bsherwood CreditAttribution: bsherwood commentedSo are you saying that checkboxes and radio buttons read the key as opposed to the label? If so can we change this to allow the select list to read the key instead?
Comment #7
asak CreditAttribution: asak commentedNo. that's not what i meant. What i meant is that when editing a node with a checkboxes field, you will properly see the labels as images, and not as code. When editing a select list field, with code for images as labels, you will see the
<img...>...</img>
code, since it cannot (and don't ask me why) be seen as images inside a select box.What you're suggesting is interesting. I have no idea if and how that can be done.
Comment #8
bsherwood CreditAttribution: bsherwood commentedWhy? Just kidding. Thanks for the response.
Comment #9
baja_tz CreditAttribution: baja_tz commentedsubscribe
Comment #10
meeotch CreditAttribution: meeotch commentedI figured out a way of doing this mostly through CSS:
YES|<span class="checkicon_text">Yes</span><img class="checkicon_icon" src="images/yes_icon.png" alt="Yes!">
then, in CSS, you can turn the text & icon (image) on and off individually, by setting the "display" attribute on the "checkicon_text" and "checkicon_icon" classes, per page or whatever. Unfortunately, this leads to some ugly-ish CSS in my case:
I'm setting the default to be icon=none, text=inline - which covers cases where the field is *edited*. In cases where the field is *viewed* I want icons, so "#user-profile" and ".view-search-page .view-content" get the opposite treatment. The former is a panel on the user profile page, and the latter is the search results on my user search page. Not exactly intuitive to read, though.
Comment #11
Anonymous (not verified) CreditAttribution: Anonymous commentedwhen I expose a filter I see the code instead the uman-readable term. I don't know how to customize following code
need help on "#user-profile .view-search-page .view-content"
and WHERE to put it
Any suggestion?
Comment #12
Fayna CreditAttribution: Fayna commentedI'm looking for a solution like this as well so subscribing!
Comment #13
Scolo CreditAttribution: Scolo commentedsubscribe
Comment #14
CyberGhost CreditAttribution: CyberGhost commentedsubscribe
Comment #15
iamalwayslost CreditAttribution: iamalwayslost commentedsubscribe
Comment #16
arosemartin CreditAttribution: arosemartin commentedThis was all I needed - worked a charm. Thanks!
Comment #17
bsherwood CreditAttribution: bsherwood commentedBumping to latest version. CCK's 6.x version might have an alternative/cleaner way to do this.
Comment #18
ntg CreditAttribution: ntg commentedsubscribing
Comment #20
brujo321 CreditAttribution: brujo321 commented<img src="/link/image.ext"></img>
don't work<img src='/link/image.ext'></img>
this workreplace " " with ' '
example:
<img src='/sites/default/files/myimage.png'></img>
Comment #21
vantuykom CreditAttribution: vantuykom commentedI have the same problem, changing quotes does not work for me
Comment #22
brujo321 CreditAttribution: brujo321 commentedread this this work.
here is a image u can see.
Comment #23
cswormy CreditAttribution: cswormy commentedHello,
I have used this solution on my xtreemhost website and it was Ok.
But when I have migrated to x10hosting, I see that it doesn't work. Why ?
Because all
<img src='/link/image.ext'></img>
are automatically converted in<img src="/link/image.ext"></img>
when you see the final html code from x10hosting. So when you save a check, you have an error message : "invalid choice, contact administrator"If you want a solution that works on all hosts, use key|label like it said in the help of CCK checkboxes :
Example : http://bilp.co.cc/parts/151-maiden-mary CCK field : Logos
Hope it will help :)
Comment #24
calefilm CreditAttribution: calefilm commentedHelped me. Thanks cswormy! I never knew what key|label was meant for. Appreciate you putting forth the time to explain.