3

I'm used to this feature in ExpressionEngine either natively or via the Auto Linker plugin, where you just wrap it around all the text fields. I've seen the Sprout Encode Email addon but that doesn't search through text and apply it. I don't mind if it doesn't create a mailto link, I just want to obfuscate every email address that appears in any of the text fields in a template.

  • What do you mean by "obfuscate", exactly? Can you give an example of how you want the email addresses to look? – Mats Mikkel Rummelhoff Feb 9 '16 at 0:41
  • I want it to convert any string of text that looks like an email address (xxx@xxx.xxx) within a text field into an encoded string to make it harder for robot harvesters. Look at the above link doc to see what the Sprout one does. – Paul Frost Feb 9 '16 at 9:13
3

I wrote a really quick Plugin for you to use that uses the _encodeStringRot13 function from the Sprout guys to use on any variable you want in Craft. What the Plugin does is to give you a new Twig filter that you can apply like this {{ entry.body|protectEmails }} and voila! - all <a href="mailto:"> will be encoded in ROT13 (reference: http://snipplr.com/view/6037/) on output.

Download it here: http://www.naboovalley.com/craft/toolkit.rar

  • Thanks, but they won't be mailto links to start with. Content authors will just type/copy the email address into the text field, so the filter needs to look for any xxx@xxx.xxx string and encode that. – Paul Frost Feb 9 '16 at 9:16
1

This email obfuscation library works really well for me, and I'm using a rich text field. Applies both to mailto links as well as unlinked email addresses.

You'll probably have to write a simple wrapper plugin to make it work as a twig extension. Also don't forget to include the library's JS file in the page's head so that it's loaded before it's needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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