Jump to content

Specify image inputfield for CKeditor


nabo
 Share

Recommended Posts

Hello

it would be nice if it could be possible to force a unique (or relative) imagefield for CKEditor.

Example
Using a repeater matrix (or repeater) with CKEditor field, the primary sources for images are imagefields in the page-repeater fieldset. Obviously I can change the page source, but I need to start from the root and this is not comfortable. In this specific situation the better solution is to have an imagefield in the parent page and force CKEditor to automatically go there... or if you want to have a "media library" go there first.

Don't know which could be the best "setting system" but in my opinion this is an annoying problem.

Link to comment
Share on other sites

6 hours ago, nabo said:

Using a repeater matrix (or repeater) with CKEditor field, the primary sources for images are imagefields in the page-repeater fieldset. Obviously I can change the page source, but I need to start from the root and this is not comfortable. In this specific situation the better solution is to have an imagefield in the parent page and force CKEditor to automatically go there

Adapting a post Ryan made in the Repeater Matrix support forum:

In /site/templates/admin.php, before the line...

require($config->paths->core . "admin.php");

...add the following...

if($page->process == 'ProcessPageEditImageSelect') {
	// The page ID that is open in Page Edit
	$edited_page_id = (int) $input->get->edit_page_id;
	// The page ID that contains the CKEditor field
	// This is where PW will look for images by default
	$cke_page_id = (int) $input->get->id;
	// If the edited page is not the same as the CKEditor page
	if($edited_page_id && $cke_page_id && $edited_page_id != $cke_page_id) {
		// Get the CKEditor page
		$cke_page = $pages->get($cke_page_id);
		// If the CKEditor page is a particular Repeater field page
		// Substitute the name of your Repeater template
		if($cke_page->template == 'repeater_your_repeater_template') {
			// Set the page ID where you want PW to look for images
			$input->get->id = $edited_page_id;
		}
	}
}

 

  • Like 4
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

×
×
  • Create New...