15 votes
Accepted

How can I link to an Asset from the Rich Text editor?

This isn't really related to Craft specifically, but to allow a user to link to an asset, you will need to enable the feature in the redactor configuration file. For example, within this file: /...
  • 4,696
12 votes
Accepted

Redactor table plugin for craft

Craft ships with Redactor’s Table plugin, but you must add it to your Redactor config yourself (in craft/config/redactor/). { // ... plugins: ['table'] } To determine which config file to ...
  • 7,248
12 votes
Accepted

Treat links in redactor/rich text field differently depending on entry type

This is a high-level question, with multiple problems to solve. First, you'll need to parse the HTML from the Rich Text field for <a> tags. Then, you'll need to find a way to match the href ...
12 votes

Image alignment and size in Redactor 2

No need for a plugin. Just add: "imageResizable": true, "imagePosition": true, to your chosen redactor config file i.e. (/craft/config/redactor/standard.json)
  • 393
12 votes
Accepted

Craft 3 Redactor Link no longer has target option

Add the linkNewTab config option to the Redactor config you're using: So, that would become something like: { "buttons": [...], "plugins": [...], "linkNewTab": true }
  • 6,308
11 votes

How do I enable redactor rich text editor in a front-end form?

It’s technically possible to include Craft’s copy of Redactor on the front end: {% includeJsResource "lib/redactor/redactor.js" %} {% includeCssResource "lib/redactor/redactor.css" %} <textarea ...
11 votes
Accepted

Redactor video plugin not working

You've probably got "Purify HTML" checked under your Rich Text field's settings and that's stripping iframe code. You should really only have that checked if you're accepting input from untrusted ...
  • 66.5k
10 votes

Can I change which 'Format' options are available in my Rich Text field?

You certainly can using the Redactor Formatting config. Locate the config file for the Redactor setting you want to edit in craft/config/redactor and add this line: "formatting": ["h1", "h2", "h3"], ...
  • 3,604
10 votes
Accepted

Does Redactor have a button that adds a horizontal rule (<hr> tag)?

Yes. Edit config/redactor/standard.json file (or the relevant file in your Craft project) and add "line" in the buttons items list. You should see the "Line" button in the toolbar which will add a ...
9 votes
Accepted

Is Redactor's default config saved as a .json file anywhere?

As @Brandon said, the defaults are hardcoded in redactor.js so there isn't a default.json file, but if there was, this is what it would be (from Craft 2.3.2615): { buttons: ['html', 'formatting', ...
  • 2,985
9 votes

How do I add custom styles/plugins to the rich text editor in Craft?

It's worth noting that as of Craft 2.5, it's now using Redactor II, so the above code examples don't work if you have upgraded. Here's a working JSON config example you can build on: { "buttons": ...
  • 403
9 votes
Accepted

apply transform to image uploaded into Redactor?

Sure, from the Redactor "Insert Image" modal:
  • 66.5k
9 votes

Redactor 2 - Can a text alignment button be added?

You can use the formattingAdd config setting to add custom formatting to the "Format" dropdown. formattingAdd: { "align-left": { "title": "Align left", "args": ["p","class","align-left"], ...
  • 35.9k
9 votes
Accepted

Change font of Redactor II

You could use the Control Panel CSS plugin that lets you add arbitrary css to the control panel. Then you could target all redactor fields like so: .redactor-layer * { font-family: 'Arial'; } ...
  • 2,301
8 votes
Accepted

Wrap embeds with HTML in rich text field

I suggest a Twig filter so you can do something like this in the template: {{ entry.body | wrapembeds }} This is something to love about Craft - the ease of building Twig filters. In the plugins ...
8 votes

HTML/View Source button not working/showing in WYSIWYG Craft 2.5 / Redactor II 1.1.0

It turns out that the latest redactor seems to now have a plugin for viewing the source. You can enable this in your redactor JSON config file under plugins. Just add the "source" plugin like so: { ...
  • 325
8 votes

Can I change which 'Format' options are available in my Rich Text field?

What I like to do is to override the default options of the Format dropdown by setting "formatting" to null and adding my own list of options using "formattingAdd". This allows you to come up with ...
  • 35.9k
7 votes
Accepted

Rich text editor Redactor adding additional paragraph p tags

http://imperavi.com/redactor/docs/settings/clean/#setting-replaceDivs http://imperavi.com/redactor/docs/settings/clean/#setting-removeEmpty http://imperavi.com/redactor/docs/settings/clean/#setting-...
  • 603
7 votes
Accepted

On entry save/update, centered text returns to left in rich text field

When you create a Rich Text field, there is an option for Clean up HTML which is checked by default. The description underneath the setting reads: Removes spans, empty tags, and most style ...
  • 3,604
7 votes
Accepted

Table button missing in Rich Text fields?

Update: since version 2.3.2621 Craft comes with Redactor's table plugin preinstalled again. So there's no need to do anything special, simply add it to your Redactor json config. Craft 2.3 now comes ...
  • 35.9k
7 votes

Where do I add custom css for the Redactor editor in the Craft control panel?

I ended up using the Control Panel CSS plugin by Lindsey D to do this. Installed the plugin and then pointed it to an external style sheet with my redactor styles. Here's the plugin: https://github....
7 votes

HTML/View Source button not working/showing in WYSIWYG Craft 2.5 / Redactor II 1.1.0

You need to add "html" in the buttons array, and not "source" in the plugins array.
7 votes

Redactor 2 - Can a text alignment button be added?

Either existing answer could work. Another option is a plugin I've recently built. Redactor Extras: https://github.com/elliotlewis/Redactor-Extras Uses the Plugin from Redactors site for align. Has ...
7 votes
Accepted

How do I add class to redactor format list?

Your example code attempts to create a new Redactor instance, which (as Brad says) won't work inside the control panel (where Craft has created the Redactor instances already). You can, however, use ...
6 votes
Accepted

Dragging images inside of rich text editor

Just looked into this and it’s a Craft bug. If you add an image manually using the “Insert URL” option, the image can be dragged around, but not if you use the “Choose image” option, which opens Craft’...
6 votes

Custom redactor.css file

You can override the control panel's CSS with a plugin. Use the popular "Control Panel CSS plugin" by Lindsey DiLoreto or make your own little one. Make use of the includeCssResource() function and ...
  • 35.9k
6 votes
Accepted

Test for empty RichText field

You can use the striptags filter to remove all HTML tags from your string. With the trim filter you can strip all whitespace from the beginning and the end of it: {% if entry.poorText|striptags|trim %...
  • 35.9k
6 votes
Accepted

Adding class to images in rich text

I wrote a plugin called Retcon HTML which will solve this nicely using PHP's DOMDocument class. You'll want to use the attr filter, which is documented here: {{ entry.richTextField | retconAttr( '...
6 votes

Rich-Text/Redactor hyperlink classes

If you only want to style how the link looks visually, and need a work-around, you could use my Redactor Styles for Craft plugin. If you add an inline style to the plugins Styles JSON object like this:...
  • 7,248

Only top scored, non community-wiki answers of a minimum length are eligible