How to obscure email and other text using signwriter and a cck formatter
Related content
- Obscure email adresses in drupal using signwriter
- Drupal how to add another formatter to a cck field using hook_field_formatter_info
- Email obfuscation module for drupal
- Gettting the labels for a cck field
- Think twice when defining a new content type
- Drupal how to render seperate fieldgroups from a content type (and a display suite trick)
- Drupal how to load content fields using cck content api avoiding node load
- Drupal module Fancy Multiselect
- Drupal how to disable a form element in a cck form using form alter
- Drupal simplenews + mime mail and php mail in general: The ghost exclamation mark!!!


For big sites
To use signwritter on sites with lots of nodes, meaning lots of images check out this issue http://drupal.org/node/880006
Empty element
If the element has no data, this wil create an empty image.
This means the label for this field will always be shown.
You should check for data before you create the image
That indeed correct. A check
That indeed correct. A check should be performed. Above function should be.
<?php
/**
* Themes an image from text
*/
function theme_your_module_formatter_text_as_image($element) {
//Validation
$string_to_obscure = $element[0]['#item']['safe'];
if (!$string_to_obscure) {
return;
}
// Set up signwriter profile
$profile->fontfile = drupal_get_path('module', 'signwriter'). '/Arial.TTF';//See this issue why its like this (<a href="http://drupal.org/node/606670" title="http://drupal.org/node/606670">http://drupal.org/node/606670</a>)
$profile->fontsize = 10;
$profile->foreground = '000000';
$profile->background = 'ffffff';
$profile->maxwidth = 600;
$profile->transparent = true;
$profile->imagetype = 'png';
$profile->disable_span = true;
$text= signwriter_title_convert($string_to_obscure, $profile);
//Some extra logic if it is an email
$output = preg_replace('/alt="[0-9a-zA-Z!@#\$%^&\*~\-\.\+\_\/=\?\|\{\}}]+"/','alt="Email Address"',$text);
return $output;
}
?>