Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codeigniter: TinyMCE image manager dynamic image paths

I have installed TinyMCE into my codeigniter build, and I have included the image manager.

In the image manager plugin (which is saved in the public/assets folder) there is a php config file which defines the image & file path constants.

define('DIR_IMAGES', 'images/path/here'); etc

The problem I have is I need the path to be dynamic depending on some data in the database, such as template_name, but I dont know how to include the right files into the config file so I can view the dynamic info.

So if the user has a template_name saved then I need the path to be

define('DIR_IMAGES', $template_name.'images/path/here');

I have also defined the template_name in a constant in core/MY_Controller.php so if I could access that variable that would be easier than doing a query to the DB but either way will work.

Can someone give me a hand with this, thanks a lot!

like image 854
Josh Avatar asked Nov 04 '22 10:11

Josh


1 Answers

I've just custom tinymce image but not using TinyMCE image manager.

but I use the tutorial from the link below.

How-to implement a custom file browser

<!-- Start tinymce custom -->
<script type="text/javascript">
 tinyMCE.init({

  <!-- 
      your tiny mce init here 
   --->


   <!-- custom file browser callback -->
   file_browser_callback : 'myFileBrowser',
 });

function myFileBrowser (field_name, url, type, win) {
  // this is your dynamic image path
  var cmsURL = "<?php echo base_url() ?>admin/media/select_image";  <== you can set as you wish
if (cmsURL.indexOf("?") < 0) {
  //add the type as the only query parameter
  cmsURL = cmsURL + "?type=" + type;
   }
else {
  //add the type as an additional query parameter
   // (PHP session ID is now included if there is one at all)
cmsURL = cmsURL + "&type=" + type;
}

   tinyMCE.activeEditor.windowManager.open({
file : cmsURL
,width : 600
,height : 600
,resizable : "yes"
,inline : "yes"
,close_previous : "yes"
,popup_css : true // Disable TinyMCE's default popup CSS
}, {
window : win,
input : field_name
});
return false;
}
</script>
like image 67
h454n Avatar answered Nov 08 '22 15:11

h454n