2

I'm having a field 'List (text)' in my custom content type as 'Select list' with Number of values as 'Unlimited', what I'm searching is to display an image instead of a value, for an instance I'm having values like Condo, Single Family & Multi Families so for these 3 different values I'm having 3 different logos which I want to display so what should I do to get this thing done?

1 Answer 1

2

I can suggest an idea I used in Views output — this may help you find a solution for your case. I needed to display an icon near an article depending on its material type. I added a hidden PHP field with the following code (image names are not directly the same as the type name, that was the brief :)):

<?php
switch ($row->type) {
case 'article':
  print 'articles'; break;
case 'gallery':
  print 'gallery'; break;
case 'music':
  print 'music';
}
?>

And then a “type” field, which had the following override:

<img src="/sites/all/themes/my_theme/images/[php].png" alt="[type]" title="[type]" width="22" height="22" />

[php] is where Views output inserts the output of the PHP field I showed earlier. This same approach can be used to add a class to the HTML tag, and define a CSS image background for each class.

I hope this helps to find a solution for your problem.

1
  • Hi, thanks for such an informative post, I still need some more info like what if I'm not using the Views module; instead of that, I'm trying to display the image directly onto my node URLs http://localhost/node-name where image is instead of the value of the 'Select List'. Thanks in advance! Commented May 10, 2012 at 12:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.