Jump to content
Matze

CKEditor - how to specify image upload fields

Recommended Posts

Hi there,

For example, if i have three image(s)-fields in a page template. And a ckeditor field. If i click on the "add image" button in the ckeditor a dialog opens (eventually with some images to choose from, if uploaded before) and a button to upload images. After clicking this button, a new dialog appears to choose from which image field to upload. In this case three fields. Is it possible to configure which fields appear at this place, or preselect one? Or only to display the image field which is meant for this purpose?

I want to avoid that a customer uploads a content image to a different field, where maybe some layout images or others are stored.

Thanks for any hints

Matze
 

Share this post


Link to post
Share on other sites

In most cases you can solve that through field permissions. Add a custom role if you need some non-superusers to change those layout images, then check "Manage Access" for the field, add your new role and remove the regular editor role. Only editable fields will be selectable as upload targets.

You should be able to preselect one image field with a piece of custom javascript (you can use AdminCustomFiles to inject your script into the correct process), but I don't have an example for that.

If you need to make things more dynamic, you probably have to do some text search and replace in the output of ProcessPageEditImagSelect::execute since the method that gets the list of target fields for the "Upload Image" button isn't hookable.

Share this post


Link to post
Share on other sites

Do you mean this? (ProcessPageEditImageSelect)

image.png.d027e410f34787de9c8a3fe5d28ad71a.png

  • Like 4

Share this post


Link to post
Share on other sites

Hi @Matze

This request sounds similar to 

You might want to check there.  It looks like Robin has posted a possible solution.

Share this post


Link to post
Share on other sites

Thank you all for your inspiration! I'll try them all.

Seems that Soma's solution will make it. Not sure what "Enter the names of any image fields (separated by a space) that you do not want to allow for selection with this module." exactly means, but a quick test hides them from the CKEditor selection. (hopefully not restricting any other functions of the field)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...