I have been using the Flexible Upload D3Z Edition WordPress plugin for a couple years now on various sites that I work on or manage. To me it provides a much easier interface to upload images while building thumbnails on the fly than the default WordPress image media upload. The issue is the Flexible Upload D3Z Edition plugin has not been updated since WordPress version 2.6.X so it has broken on more than one occasion. So when upgrading to WordPress 3 recently it broke the Flexible Upload D3Z Edition plugin and below I describe how to fix the plugin so it will operate without issue in WordPress 3.X.
Fix Flexible Upload D3Z Edition WordPress Plugin To Work With WordPress 3:
After investigating the issue I was able to locate the issue fairly quickly by determining that the plugin had been modified to only load with specific versions of WordPress. The modifications below allow the Flexible Upload D3Z Edition plugin to work with all versions of WordPress 3.X. I believe there were few changes with the wp-admin/media.php from WordPress 2.9 to WordPress 3.X so I basically just added a couple PHP if statements within the flexible-upload.php file to allow the plugin to load with WordPress 3.X. To make the modifications easier for others that want the Flexible Upload D3Z Edition WordPress plugin to work with WordPress 3 below I note the actual code added to the flexible-upload.php file followed by displaying the original flexible-upload.php file and then by displaying a completely modified flexible-upload.php file that can be inserted into the plugin’s directory to make Flexible Upload D3Z work with WordPress 3.
PHP Code Added To flexible-upload.php File For WP 3:
- if (($fup_wpver[0] == 3) && ($fup_wpver[1] >= 0)) {
- require_once(ABSPATH.$fup_rel_dir.'flexible-upload-wp26-fix.php');
- }
- if (($fup_wpver[0] == 3) && ($fup_wpver[1] < 0)) {
- // When called in the plugin context, define the filter to use this
- // script, instead of the existing inline-uploading.php script
- function flexible_upload_iframe_src($frame_src) {
- global $fup_rel_dir;
- return str_replace('inline-uploading.php', get_bloginfo('wpurl')
- .'/'.$fup_rel_dir.'flexible-upload-wp20.php',
- $frame_src);
- }
- add_filter('uploading_iframe_src', 'flexible_upload_iframe_src');
- }
- else if (($fup_wpver[0] == 3) && ($fup_wpver[1] >= 0)) {
- require_once(ABSPATH.$fup_rel_dir.'flexible-upload-wp25.php');
- }
The two IF statements in the above code should be added at line 151 of the flexible-upload.php file and the ELSE IF should be added at line 173 of the flexible-upload.php file. Below I have listed the original flexible-upload.php file as well as the new flexible-upload.php file that will allow the Flexible Upload D3Z Edition WordPress plugin to work properly with WordPress 3.X. The flexible-upload.php file is located in the “wordpress-root/wp-content/plugins/flexible-upload/” directory. Before you begin any modifications to the flexible-upload.php file make sure that you backup the original first!
Original flexible-upload.php File That Works With WordPress 2.X (First 161 Lines):
- <?php
- /*
- Plugin Name: Flexible upload D3Z Edition
- Plugin URI: http://nerdTainment.de/wp-plugins
- Description: Resize picture at upload and make thumbnail creation configurable, optionally include a watermark to your uploaded images. Support Lightbox-like plugins.
- Version: 1.13
- Author: Antoine Choppin - edited by Das3Zehn
- Author URI: http://blog.japonophile.com/
- */
- /*
- Flexible Upload plugin for Wordpress
- Copyright 2007-2008 Antoine Choppin (email: antoine@japonophile.com)
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
- /*
- Revision History:
- 0.1 Initial version (Wordpress 2.0.x)
- 1.0 Adapted to support Wordpress 2.1 too
- 1.1 Made alignment feature optional
- 1.2 Added support for WP versions older than 2.0.4
- Fixed iframe size (WP 2.0.x only)
- 1.3 Added basic option page and help page
- Supported other plugins (Greybox, Thickbox) and opening in a new window
- Supported to resize against width/height/smallest side
- 1.4 Supported top-right watermark and rotated watermark
- 1.5 Do not enlarge pictures
- Do not insert "lightbox" tag for non-image attachments
- 1.6 Multi-language support (fr_FR, ja_JP)
- Support for HighslideJS and LightWindow
- Make watermark optional and configurable for each picture
- Multi-file upload (only for WP 2.1+)
- 1.7 Fix multi-language to use plugin domain
- 1.8 Fix truncated img tag after title
- Fix problem with image deletion
- 1.9 Fix display property not working with IE
- 1.10 Major change: Adapt to WP2.5
- Implement disable wpautop to allow using captions with visual editor
- Use standard CSS (alignleft, alignright, centered) for alignment
- Fix small bugs here and there
- Support German (thx to raphaelhofer.com <email@raphaelhofer.com>)
- Support Danish (thx to Georg S. Adamsen <g.s.adamsen@gmail.com>)
- 1.11 Fix title bug, improve title & caption handling
- 1.12 Fix bug in options (WP <2.5)
- Support watermark in thumbnails and alpha blending PNG-24 watermarks
- (thanks to Michael Yates for his contribution)
- Make alt tag configurable
- Update i18n
- 1.13 Fix broken "Send to Editor" button in WP2.3.3
- Unescape special characters in caption
- 1.13+D3Z Just a quick hack to support WP 2.6 by Das3Zehn (http://nerdTainment.de)
- */
- /*
- Features:
- =========
- - automatically resize picture at upload
- - create thumbnail of the desired size
- - include watermark in every uploaded picture
- - support for picture alignment (left/right/center)
- - support for picture caption (not when using tinyMCE)
- - include Lightbox "rel" tag
- Supported WP versions:
- ======================
- - WP 2.0.x (2.0, 2.0.1, 2.0.2, 2.0.4, 2.0.5, 2.0.6, 2.0.7, 2.0.8, 2.0.9)
- - WP 2.1.x (2.1, 2.1.2)
- - WP 2.2.x
- - WP 2.3.x
- - WP 2.5
- - WP 2.6
- Usage:
- ======
- - unzip flexible-upload.zip in your wp-content/plugins directory
- - go to Flexible Upload option page in the admin menu and configure it
- to suit your needs
- - [optional] install Lightbox2 plugin or similar
- */
- define('FUP_DEFAULT_LARGE_OPTION', 'fup_default_large_max');
- define('FUP_DEFAULT_THUMB_OPTION', 'fup_default_thumb_max');
- define('FUP_RESIZE_SIDE_OPTION', 'fup_resize_side');
- define('FUP_THUMB_SIDE_OPTION', 'fup_thumb_side');
- define('FUP_ALIGNMENT_MODE_OPTION', 'fup_alignment_mode');
- define('FUP_DEFAULT_ALIGN_OPTION', 'fup_default_alignment');
- define('FUP_WATERMARK_PIC_OPTION', 'fup_watermark_picture');
- define('FUP_WATERMARK_THUMB_OPTION','fup_watermark_thumbnail');
- define('FUP_DEFAULT_WAT_LOC_OPTION','fup_default_wat_location');
- define('FUP_DEFAULT_WAT_ORI_OPTION','fup_default_wat_orientation');
- define('FUP_WAT_OPT_PER_PIC_OPTION','fup_wat_opt_per_picture');
- define('FUP_PIC_TARGET_OPTION', 'fup_picture_target');
- define('FUP_JPEG_QUALITY_OPTION', 'fup_jpeg_quality');
- define('FUP_IMAGE_TITLE_OPTION', 'fup_image_title');
- define('FUP_IMAGE_ALT_OPTION', 'fup_image_alt');
- define('FUP_DISABLE_WPAUTOP_OPTION','fup_disable_wpautop');
- define('FUP_DEFAULT_CAPTION_OPTION','fup_default_caption');
- //Check install directory
- $fup_directory = 'wp-content/plugins/flexible-upload/';
- if ((!strstr(dirname(__FILE__).'/', $fup_directory)) &&
- (!strstr(dirname(__FILE__).'\\', str_replace('/', '\\', $fup_directory)))) {
- trigger_error(sprintf(__('<b>Flexible Upload is not installed in the proper directory!</b><br />It won\'t work until installed in <b>%s</b><br />', 'fup'), $fup_directory), E_USER_ERROR);
- return;
- }
- global $wp_version;
- global $fup_wpver;
- // WP ME support, thanks to Bono-san http://bono.s201.xrea.com/
- $fup_wpver = str_replace("ME", "", $wp_version);
- $fup_wpver = explode('.', $fup_wpver);
- $fup_rel_dir = 'wp-content/plugins/flexible-upload/';
- // Multi-language support
- if (defined('WPLANG') && function_exists('load_plugin_textdomain')) {
- load_plugin_textdomain('fup', $fup_rel_dir.'languages');
- }
- if (($fup_wpver[0] == 2) && ($fup_wpver[1] >= 6)) {
- require_once(ABSPATH.$fup_rel_dir.'flexible-upload-wp26-fix.php');
- }
- if (($fup_wpver[0] == 2) && ($fup_wpver[1] < 1)) {
- // When called in the plugin context, define the filter to use this
- // script, instead of the existing inline-uploading.php script
- function flexible_upload_iframe_src($frame_src) {
- global $fup_rel_dir;
- return str_replace('inline-uploading.php', get_bloginfo('wpurl')
- .'/'.$fup_rel_dir.'flexible-upload-wp20.php',
- $frame_src);
- }
- add_filter('uploading_iframe_src', 'flexible_upload_iframe_src');
- }
- else if (($fup_wpver[0] == 2) && ($fup_wpver[1] >= 1) && ($fup_wpver[1] < 5)) {
- require_once(ABSPATH.$fup_rel_dir.'flexible-upload-wp21.php');
- }
- else if (($fup_wpver[0] == 2) && ($fup_wpver[1] >= 5)) {
- require_once(ABSPATH.$fup_rel_dir.'flexible-upload-wp25.php');
- }
- // else WP version not supported
- /**
- * Activate plugin
- */
New flexible-upload.php File That Works With WordPress 3.X (First 180 Lines):
- <?php
- /*
- Plugin Name: Flexible upload D3Z Edition
- Plugin URI: http://nerdTainment.de/wp-plugins
- Description: Resize picture at upload and make thumbnail creation configurable, optionally include a watermark to your uploaded images. Support Lightbox-like plugins.
- Version: 1.13
- Author: Antoine Choppin - edited by Das3Zehn
- Author URI: http://blog.japonophile.com/
- */
- /*
- Flexible Upload plugin for Wordpress
- Copyright 2007-2008 Antoine Choppin (email: antoine@japonophile.com)
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
- /*
- Revision History:
- 0.1 Initial version (Wordpress 2.0.x)
- 1.0 Adapted to support Wordpress 2.1 too
- 1.1 Made alignment feature optional
- 1.2 Added support for WP versions older than 2.0.4
- Fixed iframe size (WP 2.0.x only)
- 1.3 Added basic option page and help page
- Supported other plugins (Greybox, Thickbox) and opening in a new window
- Supported to resize against width/height/smallest side
- 1.4 Supported top-right watermark and rotated watermark
- 1.5 Do not enlarge pictures
- Do not insert "lightbox" tag for non-image attachments
- 1.6 Multi-language support (fr_FR, ja_JP)
- Support for HighslideJS and LightWindow
- Make watermark optional and configurable for each picture
- Multi-file upload (only for WP 2.1+)
- 1.7 Fix multi-language to use plugin domain
- 1.8 Fix truncated img tag after title
- Fix problem with image deletion
- 1.9 Fix display property not working with IE
- 1.10 Major change: Adapt to WP2.5
- Implement disable wpautop to allow using captions with visual editor
- Use standard CSS (alignleft, alignright, centered) for alignment
- Fix small bugs here and there
- Support German (thx to raphaelhofer.com <email@raphaelhofer.com>)
- Support Danish (thx to Georg S. Adamsen <g.s.adamsen@gmail.com>)
- 1.11 Fix title bug, improve title & caption handling
- 1.12 Fix bug in options (WP <2.5)
- Support watermark in thumbnails and alpha blending PNG-24 watermarks
- (thanks to Michael Yates for his contribution)
- Make alt tag configurable
- Update i18n
- 1.13 Fix broken "Send to Editor" button in WP2.3.3
- Unescape special characters in caption
- 1.13+D3Z Just a quick hack to support WP 2.6 by Das3Zehn (http://nerdTainment.de)
- */
- /*
- Features:
- =========
- - automatically resize picture at upload
- - create thumbnail of the desired size
- - include watermark in every uploaded picture
- - support for picture alignment (left/right/center)
- - support for picture caption (not when using tinyMCE)
- - include Lightbox "rel" tag
- Supported WP versions:
- ======================
- - WP 2.0.x (2.0, 2.0.1, 2.0.2, 2.0.4, 2.0.5, 2.0.6, 2.0.7, 2.0.8, 2.0.9)
- - WP 2.1.x (2.1, 2.1.2)
- - WP 2.2.x
- - WP 2.3.x
- - WP 2.5
- - WP 2.6
- Usage:
- ======
- - unzip flexible-upload.zip in your wp-content/plugins directory
- - go to Flexible Upload option page in the admin menu and configure it
- to suit your needs
- - [optional] install Lightbox2 plugin or similar
- */
- define('FUP_DEFAULT_LARGE_OPTION', 'fup_default_large_max');
- define('FUP_DEFAULT_THUMB_OPTION', 'fup_default_thumb_max');
- define('FUP_RESIZE_SIDE_OPTION', 'fup_resize_side');
- define('FUP_THUMB_SIDE_OPTION', 'fup_thumb_side');
- define('FUP_ALIGNMENT_MODE_OPTION', 'fup_alignment_mode');
- define('FUP_DEFAULT_ALIGN_OPTION', 'fup_default_alignment');
- define('FUP_WATERMARK_PIC_OPTION', 'fup_watermark_picture');
- define('FUP_WATERMARK_THUMB_OPTION','fup_watermark_thumbnail');
- define('FUP_DEFAULT_WAT_LOC_OPTION','fup_default_wat_location');
- define('FUP_DEFAULT_WAT_ORI_OPTION','fup_default_wat_orientation');
- define('FUP_WAT_OPT_PER_PIC_OPTION','fup_wat_opt_per_picture');
- define('FUP_PIC_TARGET_OPTION', 'fup_picture_target');
- define('FUP_JPEG_QUALITY_OPTION', 'fup_jpeg_quality');
- define('FUP_IMAGE_TITLE_OPTION', 'fup_image_title');
- define('FUP_IMAGE_ALT_OPTION', 'fup_image_alt');
- define('FUP_DISABLE_WPAUTOP_OPTION','fup_disable_wpautop');
- define('FUP_DEFAULT_CAPTION_OPTION','fup_default_caption');
- //Check install directory
- $fup_directory = 'wp-content/plugins/flexible-upload/';
- if ((!strstr(dirname(__FILE__).'/', $fup_directory)) &&
- (!strstr(dirname(__FILE__).'\\', str_replace('/', '\\', $fup_directory)))) {
- trigger_error(sprintf(__('<b>Flexible Upload is not installed in the proper directory!</b><br />It won\'t work until installed in <b>%s</b><br />', 'fup'), $fup_directory), E_USER_ERROR);
- return;
- }
- global $wp_version;
- global $fup_wpver;
- // WP ME support, thanks to Bono-san http://bono.s201.xrea.com/
- $fup_wpver = str_replace("ME", "", $wp_version);
- $fup_wpver = explode('.', $fup_wpver);
- $fup_rel_dir = 'wp-content/plugins/flexible-upload/';
- // Multi-language support
- if (defined('WPLANG') && function_exists('load_plugin_textdomain')) {
- load_plugin_textdomain('fup', $fup_rel_dir.'languages');
- }
- if (($fup_wpver[0] == 2) && ($fup_wpver[1] >= 6)) {
- require_once(ABSPATH.$fup_rel_dir.'flexible-upload-wp26-fix.php');
- }
- if (($fup_wpver[0] == 2) && ($fup_wpver[1] < 1)) {
- // When called in the plugin context, define the filter to use this
- // script, instead of the existing inline-uploading.php script
- function flexible_upload_iframe_src($frame_src) {
- global $fup_rel_dir;
- return str_replace('inline-uploading.php', get_bloginfo('wpurl')
- .'/'.$fup_rel_dir.'flexible-upload-wp20.php',
- $frame_src);
- }
- add_filter('uploading_iframe_src', 'flexible_upload_iframe_src');
- }
- if (($fup_wpver[0] == 3) && ($fup_wpver[1] >= 0)) {
- require_once(ABSPATH.$fup_rel_dir.'flexible-upload-wp26-fix.php');
- }
- if (($fup_wpver[0] == 3) && ($fup_wpver[1] < 0)) {
- // When called in the plugin context, define the filter to use this
- // script, instead of the existing inline-uploading.php script
- function flexible_upload_iframe_src($frame_src) {
- global $fup_rel_dir;
- return str_replace('inline-uploading.php', get_bloginfo('wpurl')
- .'/'.$fup_rel_dir.'flexible-upload-wp20.php',
- $frame_src);
- }
- add_filter('uploading_iframe_src', 'flexible_upload_iframe_src');
- }
- else if (($fup_wpver[0] == 2) && ($fup_wpver[1] >= 1) && ($fup_wpver[1] < 5)) {
- require_once(ABSPATH.$fup_rel_dir.'flexible-upload-wp21.php');
- }
- else if (($fup_wpver[0] == 2) && ($fup_wpver[1] >= 5)) {
- require_once(ABSPATH.$fup_rel_dir.'flexible-upload-wp25.php');
- }
- else if (($fup_wpver[0] == 3) && ($fup_wpver[1] >= 0)) {
- require_once(ABSPATH.$fup_rel_dir.'flexible-upload-wp25.php');
- }
- // else WP version not supported
- /**
- * Activate plugin
- */
That should be the only modification you need to get the Flexible Upload D3Z Edition WP plugin working with WordPress 3. The below images display an example of what the Flexible Upload D3Z Edition plugin will look like when operating properly.
Flexible Upload D3Z Edition WP Plugin Working On WordPress 3:
Some people will prefer the default image upload within WordPress including the Flash Upload or the Browser Upload however in my case I prefer the Flexible Upload D3Z Edition WordPress plugin.