I'm attempting to create entries from a front end form with redactor for the main body content. We have an asset file upload field for the main image but we also need assets within the body text as per a normal wysiwyg editor. Basically like this editor I am writing in right now!

I have this all working except for the images within redactor using the following:

{% do view.registerAssetBundle("craft\\redactor\\assets\\redactor\\RedactorAsset") %}
<label for="copy">Submission{% include '_includes/required' %}</label>
<textarea id="copy" name="fields[copy]" rows="10" required></textarea>
{% set redactor_js %}
  $R('#copy', {
    "buttons": ["format", "bold", "italic", "lists", "link", "image", "video", "alignment", "file"],
    "formatting": ["p","blockquote","h2","h3","h4","h5","h6"],
{% endset %}
{% js redactor_js %}

I have an image upload button which triggers the image uploader and I can add an asset to it but then the image fails to upload.

I believe I need some sort of other library to actually run the upload. From direct emails with Craft they suggested adding the following library: {% do view.registerAssetBundle("craft\\redactor\\assets\\field\\FieldAsset") %} Which adds in a bunch of extra CSS and removed the image upload button but didnt seem to help much.

I have found some old info here: How can I insert images into a Redactor rich text field in a front-end form? but with no real solution that seems up to date or verified to work.

Anyone have a viable solution? Happy to use a different editor if it helps...like this one!!?


Your Answer

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

Browse other questions tagged or ask your own question.