Simple Image Upload Plugin for TinyMCE
A very simple image upload plugin for TinyMCE. It is free and opensource.
Features
With TinyMCE Images Upload plugin you can:
— Upload images in 2 clicks
— Activate Image auto-resize. The maximum width and height of an image can be specified in config file.
— Disable uploads that exceed the maximum image width, height or the maximum file size.
— Disable image file formats that are not marked as allowed.
Requirements
— PHP5, or PHP4. Application has been tested on PHP 5.2.9-2. (PHP4 should also work well).
— TinyMCE 3. x.x.
Setup
1. Download distribution pack. Unzip it into TinyMCE’s plugins folder.
2. Edit config.php file found in plugins/markettoimages. Minimally, you should only specify a target directory for your uploads. Every block of config. php is well-commented, so I think everything should go right.
3. Activate markettoimages plugin and add markettoimages button in TinyMCE. Don’t forget to set theme:advanced and realtive_urls:false. See an exmple below:
tinyMCE.init({
theme : "advanced",
relative_urls : false,
plugins : "markettoimages, ***",
theme_advanced_buttons1 : "markettoimages,|,***"
* * *
});
Full implementation:
<script type="text/javascript" src="/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
// General options
mode : "textareas",
theme : "advanced",
plugins : "markettoimages,safari,table,save,inlinepopups,contextmenu,paste",
// Theme options
theme_advanced_buttons1 : "save,|,bold,italic,underline,strikethrough,|,formatselect,|,markettoimages",
theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,bullist,numlist,|,outdent,indent,|,link,unlink,cleanup,code",
theme_advanced_buttons3 : "tablecontrols,|,sub,sup,|,fullscreen,|,justifyleft,justifycenter,justifyright,",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_blockformats : "p,h1,h2",
theme_advanced_resizing : true,
// Other options
relative_urls : false
});
</script>
4. In case, when TinyMCE’s folder is not protected with HTTP Authorisation, you should require is_allowed() function to return `TRUE` if user is authorised, `FALSE` - otherwise. is_allowed() is found at plugins/markettoimages/is_allowed.php of your TinyMCE installation. Simple example below:
<?php
function is_allowed()
{
global $_COOKIE, $_SERVER;
$allow_login = "admin";
$allow_pass = "george12345";
$ip = $_SERVER['REMOTE_ADDR'];
if
(
isset($_COOKIE['login'], $_COOKIE['passhash'])
and $_COOKIE['login'] == $allow_login
and $_COOKIE['passhash'] == md5(md5($ip).md5($allow_pass))
)
{
return TRUE;
}
return FALSE;
}
?>