Jump to content

CKEditor - how to specify image upload fields


Matze
 Share

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
 

Link to comment
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.

Link to comment
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)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...