Setting up the Image Gallery Path

Rich Text Editor for PHP

To enable the image management function of the RichTextEditor control, you must set up a managed image gallery folder.

This is simply a folder in which you will be placing images for your users to use in their content. Create a folder in your application's root folder. The folder can be named something like "/uploads/", "/images" or "/UserImages".

Make sure that the Internet Guest Account has Read+Write permissions on this folder and its contents.

How to specify the Image gallery path?

You can easily specify the image gallery path using the following methods:

Edit security policy file

The security policy file (default.config, admin.config and guest.config) can be found in the richtexteditor/config folder. In security policy file you can find the following code which defines the image gallery path information within RichTextEditor. By default, insert gallery dialog and insert image dialog share the same value:

<category for="Gallery,Image">
       <security name="Extensions">*.jpg,*.jpeg,*.gif,*.png</security>
       <security name="MimeTypes">image/*</security>
       <storage id="default>
              <security name="StoragePath">~/uploads</security>
              <security name="StorageName">Image Files</security><!-- storage display name -->
       </storage>
</category>

If you want insert gallery dialog and insert image dialog have the different settings, you need to create separate categories for gallery dialog and image dialog:

<category for="Gallery"><!-- Image Gallery Dialog -->  
       <security name="Extensions">*.jpg,*.jpeg,*.gif,*.png</security>
       <security name="MimeTypes">image/*</security>
       <storage id="default>
              <security name="StoragePath">~/uploads</security>
              <security name="StorageName">Image Files</security><!-- storage display name -->
       </storage>
</category>
<category for="Image"><!-- Insert Image Dialog -->  
       <security name="Extensions">*.jpg,*.jpeg,*.gif,*.png</security>
       <security name="MimeTypes">image/*</security>
       <storage id="default>
              <security name="StoragePath">~/uploads2</security>
              <security name="StorageName">Image Files</security><!-- storage display name -->
       </storage>
</category>

If you want to add new folders as image gallery path, you need to create new storages and specify the storgae ID, name, path.

<category for="Gallery,Image">
       <storage id="newimagepath>
              <security name="StorageName">New Images</security><!-- storage display name -->
              <security name="StoragePath">~/newimagepath</security>
       </storage>
       <storage id="newimagepath2>
              <security name="StorageName">New Images2</security><!-- storage display name -->
              <security name="StoragePath">~/newimagepath2</security>
       </storage>
</category>

Programmatically specify the Image gallery path

RichTextEditor provides a powerful method named Editor.SetSecurity that allows you programmatically manage the security settings.

1. Set insert gallery path using the default storage

$rte->SetSecurity("Gallery", "default", "StoragePath", "~/uploads"); 
$rte->SetSecurity("Gallery", "default", "StorageName", "Uploads");

This is equivalent to the following code:

<category for="Gallery"><!-- Image Gallery Dialog -->  
       <storage id="default>
              <security name="StoragePath">~/uploads</security>
              <security name="StorageName">Image Files</security><!-- storage display name -->
       </storage>
</category>

2. Create a new storage for insert gallery dialog/insert image dialog and specify the ID, name and path

$rte->SetSecurity("Gallery", "newimagepath", "StoragePath", "~/newimagepath"); 
$rte->SetSecurity("Gallery", "newimagepath ", "StorageName", "New Images");
$rte->SetSecurity("Image", "newimagepath", "StoragePath", "~/newimagepath"); 
$rte->SetSecurity("Image", "newimagepath ", "StorageName", "New Images");

This is equivalent to the following code:

<category for="Gallery,Image">
       <storage id="newimagepath>
              <security name="StorageName">New Images</security>
              <security name="StoragePath">~/newimagepath</security>
       </storage>
</category>

3. To programmatically disable a storage access, you can use the following method:

$rte->SetSecurity("Gallery", "newimagepath", "AllowAccess", "false"); 

In the above code, insert gallery dialog access to a storage is disabled. The storage ID in the above code is "newimagepath".


Send feedback about this topic to CuteSoft. © 2003 - 2012 CuteSoft Components Inc. All rights reserved.