Examples of types of fields which contain characters that could be displayed as images:
Computed (http://drupal.org/project/computed_field); especially this one is important, as it could be configured to copy contents of other (non-text) field types.
Content Taxonomy Fields,
Date,
Datestamp,
Datetime,
Decimal,
E-mail (useful against spammers harvesting email-addresses; though other modules exist to achieve this)
Float,
Integer,
Node reference,
Role reference,
Text,
User reference.

Comments

deciphered’s picture

Priority: Normal » Minor
Status: Active » Postponed

Hi not_Dries_Buytaert,

While what you request has merit, and I believe that the current dev already has support for the email widget, generally each widget provides a differently structured variable so a single formatter would not suffice.

What I would suggest is using the Custom Formatters module, where you can easily define your own CCK formatters as needed, giving you much more control than a module defined CCK formatter.

 

Here's a example email formatter I knocked up for you, after first creating a textimage called 'email'.

Name: email_textimage
Label: Email Textimage

Field Types: email
Handle multiple values: off (default)

Code:
return theme('textimage_image', 'email', $element['#item']['safe']);

 

I'm not specifically saying that I won't expand the formatter somewhat in the future, but there a more major issues with Textimage at the minute.

Cheers,
Deciphered.

not_Dries_Buytaert’s picture

@Deciphered: Thx for the email widget/ formatter example.
How could the module automatically create images from computed/ calculated fields (http://drupal.org/project/computed_field)?
Perhaps you could share with us which: variable holds the unsanitized input string for this module or handle should be used?
Really hoping you can help out with this request. :-)

not_Dries_Buytaert’s picture

Priority: Minor » Normal
Status: Postponed » Active

@Deciphered: thx to your hint, I figured out following workaround to display any type of field as an image:

  1. Install and enable the module 'Textimage' (admin/build/modules)
  2. Install and enable the module 'Custom Formatters' (admin/build/modules)
  3. Install and enable the module 'Computed Field' (admin/build/modules)
  4. Add a textimage preset (admin/settings/textimage/preset/new) using following settings:
    Preset name: textimage_preset_name
  5. Add a custom formatter (admin/settings/formatters/add) using following settings:
    Name: custom_formatter_name
    Label: custom_formatter_label
    Description: custom_formatter_description
    Editor mode: Advanced
    {click Next button}
    Field type(s): computed
    Handle multiple values: disabled
    PHP: return theme('textimage_image', 'textimage_preset_name', $element['#item']['value']);
  6. Add a computed field to a content type (admin/content/node-type/{content type type}/fields) using following settings:
    Computed Code: $node_field[0]['value'] = $node->{user input field NAME}[0]['value'];
    NB: change the part between '{...}' as needed.
    Data Length: {some value; I use '1024'}
    Sortable: {uncheck}
  7. Change the values of the label and both displays (Teaser and Full node) of the user input field (admin/content/node-type/{content type type}/display) to 'Hidden'.
    NB: change the part between '{...}' as needed.
  8. Change the values of the label and both displays (Teaser and Full node) of the added computed field (admin/content/node-type/{content type type}/display) to 'Custom: custom_formatter_label'.
    NB: change the part between '{...}' as needed.
  9. Create a node of the content type which contains the user input field and check whether the value of that field is displayed as an image.

Please, refer to these 'how to' instructions on the project webpage and/ or in the readme.

To change the extension, alt and title of the computed image, I entered following alternative code in step 3:
return theme('textimage_image', 'textimage_preset_name', $element['#item']['value'], 'png', 'MY_alt', 'MY_title');
which results in following error:

Unable to generate Textimage as the file extension is unsupported on this system. Files must have a .png, .jpg, or .gif extension.

Quote from project webpage:

Use the theme_textimage_image() function at the theme/module level with the following format:
theme('textimage_image', 'Preset', 'Text', array('Additional', 'Text'), 'extension', 'alt', 'title')

Is this a bug and (if so) in which module?

mogop’s picture

thanks! very helpful.
when your text_image_preset doesn't have background the image is .png.

any idea how to add class to the image and same "alt" and "title" as the value?

mogop’s picture

how to get the Suffix and Prefix? the image created is only from Value!

mondrake’s picture

Issue summary: View changes
Status: Active » Closed (outdated)