Version Description
- Fixed 'Cannot use string offset as an array' error
Download this release
Release Info
Developer | tomasz.sita |
Plugin | Manual Image Crop |
Version | 1.07 |
Comparing to | |
See all releases |
Code changes from version 1.06 to 1.07
- lib/ManualImageCrop.php +5 -5
- lib/ManualImageCropEditorWindow.php +1 -2
- lib/ManualImageCropSettingsPage.php +189 -171
- manual-image-crop.php +2 -2
- readme.txt +5 -2
lib/ManualImageCrop.php
CHANGED
@@ -153,11 +153,11 @@ setInterval(function() {
|
|
153 |
|
154 |
|
155 |
$src_file = str_replace($uploadsDir['baseurl'], $uploadsDir['basedir'], $src_file_url[0]);
|
156 |
-
$dst_file_url = wp_get_attachment_image_src($_POST['attachmentId'], $_POST['editedSize']);
|
157 |
-
|
158 |
-
if (!$dst_file_url) {
|
159 |
-
exit;
|
160 |
-
}
|
161 |
$dst_file = str_replace($uploadsDir['baseurl'], $uploadsDir['basedir'], $dst_file_url[0]);
|
162 |
|
163 |
|
153 |
|
154 |
|
155 |
$src_file = str_replace($uploadsDir['baseurl'], $uploadsDir['basedir'], $src_file_url[0]);
|
156 |
+
$dst_file_url = wp_get_attachment_image_src($_POST['attachmentId'], $_POST['editedSize']);
|
157 |
+
|
158 |
+
if (!$dst_file_url) {
|
159 |
+
exit;
|
160 |
+
}
|
161 |
$dst_file = str_replace($uploadsDir['baseurl'], $uploadsDir['basedir'], $dst_file_url[0]);
|
162 |
|
163 |
|
lib/ManualImageCropEditorWindow.php
CHANGED
@@ -24,8 +24,7 @@ class ManualImageCropEditorWindow {
|
|
24 |
}
|
25 |
|
26 |
public function renderWindow() {
|
27 |
-
$
|
28 |
-
$sizesSettings = unserialize( $sizes_settings['sizes_settings'] );
|
29 |
?>
|
30 |
<div class="mic-editor-wrapper">
|
31 |
<h4><?php _e('Pick the image size:','microp'); ?></h4>
|
24 |
}
|
25 |
|
26 |
public function renderWindow() {
|
27 |
+
$sizesSettings = MicSettingsPage::getSettings();
|
|
|
28 |
?>
|
29 |
<div class="mic-editor-wrapper">
|
30 |
<h4><?php _e('Pick the image size:','microp'); ?></h4>
|
lib/ManualImageCropSettingsPage.php
CHANGED
@@ -1,172 +1,190 @@
|
|
1 |
-
<?php
|
2 |
-
class MicSettingsPage
|
3 |
-
{
|
4 |
-
/**
|
5 |
-
* Holds the values to be used in the fields callbacks
|
6 |
-
*/
|
7 |
-
private $options;
|
8 |
-
|
9 |
-
/**
|
10 |
-
* Start up
|
11 |
-
*/
|
12 |
-
public function __construct()
|
13 |
-
{
|
14 |
-
add_action( 'admin_menu', array( $this, 'add_plugin_page' ) );
|
15 |
-
add_action( 'admin_init', array( $this, 'page_init' ) );
|
16 |
-
}
|
17 |
-
|
18 |
-
/**
|
19 |
-
*
|
20 |
-
|
21 |
-
|
22 |
-
{
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
}
|
1 |
+
<?php
|
2 |
+
class MicSettingsPage
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Holds the values to be used in the fields callbacks
|
6 |
+
*/
|
7 |
+
private $options;
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Start up
|
11 |
+
*/
|
12 |
+
public function __construct()
|
13 |
+
{
|
14 |
+
add_action( 'admin_menu', array( $this, 'add_plugin_page' ) );
|
15 |
+
add_action( 'admin_init', array( $this, 'page_init' ) );
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Fix of settings serialized twice or more
|
20 |
+
* @return mixed
|
21 |
+
*/
|
22 |
+
static function getSettings() {
|
23 |
+
$micOptions = get_option( 'mic_options' );
|
24 |
+
if ( ! isset( $micOptions['sizes_settings'] ) ) {
|
25 |
+
return array();
|
26 |
+
}
|
27 |
+
$settings = unserialize( $micOptions['sizes_settings'] );
|
28 |
+
$i = 0;
|
29 |
+
while ( ! empty($settings) && ! is_array($settings) ) {
|
30 |
+
if ($i++ == 10) {
|
31 |
+
break;
|
32 |
+
}
|
33 |
+
$settings = unserialize($settings);
|
34 |
+
}
|
35 |
+
return $settings;
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Add options page
|
40 |
+
*/
|
41 |
+
public function add_plugin_page()
|
42 |
+
{
|
43 |
+
// This page will be under "Settings"
|
44 |
+
add_options_page(
|
45 |
+
'Settings Admin',
|
46 |
+
'Manual Image Crop',
|
47 |
+
'manage_options',
|
48 |
+
'Mic-setting-admin',
|
49 |
+
array( $this, 'create_admin_page' )
|
50 |
+
);
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Options page callback
|
55 |
+
*/
|
56 |
+
public function create_admin_page()
|
57 |
+
{
|
58 |
+
?>
|
59 |
+
<div class="wrap">
|
60 |
+
<?php screen_icon(); ?>
|
61 |
+
<h2>Manual Image Crop Settings</h2>
|
62 |
+
<form method="post" action="options.php" class="mic-settings-page">
|
63 |
+
<?php
|
64 |
+
// This prints out all hidden setting fields
|
65 |
+
settings_fields( 'mic_options_group' );
|
66 |
+
do_settings_sections( 'Mic-setting-admin' );
|
67 |
+
submit_button();
|
68 |
+
?>
|
69 |
+
</form>
|
70 |
+
</div>
|
71 |
+
<?php
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Register and add settings
|
76 |
+
*/
|
77 |
+
public function page_init()
|
78 |
+
{
|
79 |
+
register_setting(
|
80 |
+
'mic_options_group', // Option group
|
81 |
+
'mic_options', // Option name
|
82 |
+
array( $this, 'sanitize' ) // Sanitize
|
83 |
+
);
|
84 |
+
|
85 |
+
add_settings_section(
|
86 |
+
'setting_section_id', // ID
|
87 |
+
'Mic Custom Settings', // Title
|
88 |
+
array( $this, 'print_section_info' ), // Callback
|
89 |
+
'Mic-setting-admin' // Page
|
90 |
+
);
|
91 |
+
|
92 |
+
add_settings_field(
|
93 |
+
'sizes_settings', // ID
|
94 |
+
'Crop sizes settings', // Title
|
95 |
+
array( $this, 'sizes_settings_callback' ), // Callback
|
96 |
+
'Mic-setting-admin', // Page
|
97 |
+
'setting_section_id' // Section
|
98 |
+
);
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Sanitize each setting field as needed
|
103 |
+
*
|
104 |
+
* @param array $input Contains all settings fields as array keys
|
105 |
+
*/
|
106 |
+
public function sanitize( $input )
|
107 |
+
{
|
108 |
+
$new_input = array();
|
109 |
+
if( isset( $input['sizes_settings'] ) ) {
|
110 |
+
$new_input['sizes_settings'] = serialize( $input['sizes_settings'] );
|
111 |
+
}
|
112 |
+
return $new_input;
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Print the Section text
|
117 |
+
*/
|
118 |
+
public function print_section_info()
|
119 |
+
{
|
120 |
+
print 'Enter your settings below:';
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Get the settings option array and print one of its values
|
125 |
+
*/
|
126 |
+
public function sizes_settings_callback()
|
127 |
+
{
|
128 |
+
global $_wp_additional_image_sizes;
|
129 |
+
|
130 |
+
$imageSizes = get_intermediate_image_sizes();
|
131 |
+
|
132 |
+
$sizeLabels = apply_filters( 'image_size_names_choose', array(
|
133 |
+
'thumbnail' => __('Thumbnail'),
|
134 |
+
'medium' => __('Medium'),
|
135 |
+
'large' => __('Large'),
|
136 |
+
'full' => __('Full Size'),
|
137 |
+
) );
|
138 |
+
$sizeLabels = apply_filters( 'image_size_names_choose', array() );
|
139 |
+
|
140 |
+
echo '<table class="widefat fixed" cellspacing="0">';
|
141 |
+
echo '<thead>
|
142 |
+
<tr>
|
143 |
+
<th>' . __('Size', 'microp') . '</th>
|
144 |
+
<th>' . __('Visible', 'microp') . '</th>
|
145 |
+
<th>' . __('Default JPEG Quality', 'microp') . '</th>
|
146 |
+
<th>' . __('Custom Label', 'microp') . '</th>
|
147 |
+
</tr>
|
148 |
+
</thead>
|
149 |
+
<tbody>';
|
150 |
+
|
151 |
+
$sizesSettings = self::getSettings();
|
152 |
+
|
153 |
+
foreach ($imageSizes as $s) {
|
154 |
+
$label = isset($sizeLabels[$s]) ? $sizeLabels[$s] : ucfirst( str_replace( '-', ' ', $s ) );
|
155 |
+
if (isset($_wp_additional_image_sizes[$s])) {
|
156 |
+
$cropMethod = $_wp_additional_image_sizes[$s]['crop'];
|
157 |
+
} else {
|
158 |
+
$cropMethod = get_option($s.'_crop');
|
159 |
+
}
|
160 |
+
|
161 |
+
if ($cropMethod == 0) {
|
162 |
+
continue;
|
163 |
+
}
|
164 |
+
|
165 |
+
echo '<tr>
|
166 |
+
<td>' . $label. '</td>
|
167 |
+
<td><select name="mic_options[sizes_settings][' . $s . '][visibility]">
|
168 |
+
<option value="visible">' . __('Yes', 'microp') . '</option>
|
169 |
+
<option value="hidden" ' . ( $sizesSettings[$s]['visibility'] == 'hidden' ? 'selected' : '' ) . '>' . __('No', 'microp') . '</option>
|
170 |
+
</select></td>
|
171 |
+
<td><select name="mic_options[sizes_settings][' . $s . '][quality]">
|
172 |
+
<option value="100">' . __('100 (best quality, biggest file)', 'microp') . '</option>
|
173 |
+
<option value="80" ' . ( !isset ($sizesSettings[$s]['quality']) || $sizesSettings[$s]['quality'] == '80' ? 'selected' : '' ) . '>' . __('80 (very high quality)', 'microp') . '</option>
|
174 |
+
<option value="70" ' . ( $sizesSettings[$s]['quality'] == '70' ? 'selected' : '' ) . '>' . __('70 (high quality)', 'microp') . '</option>
|
175 |
+
<option value="60" ' . ( $sizesSettings[$s]['quality'] == '60' ? 'selected' : '' ) . '>' . __('60 (good)', 'microp') . '</option>
|
176 |
+
<option value="50" ' . ( $sizesSettings[$s]['quality'] == '50' ? 'selected' : '' ) . '>' . __('50 (average)', 'microp') . '</option>
|
177 |
+
<option value="30" ' . ( $sizesSettings[$s]['quality'] == '30' ? 'selected' : '' ) . '>' . __('30 (low)', 'microp') . '</option>
|
178 |
+
<option value="10" ' . ( $sizesSettings[$s]['quality'] == '10' ? 'selected' : '' ) . '>' . __('10 (very low, smallest file)', 'microp') . '</option>
|
179 |
+
</select></td>
|
180 |
+
<td><input name="mic_options[sizes_settings][' . $s . '][label]" type="text" placeholder="' . $label . '" value="' . str_replace('"', '"', $sizesSettings[$s]['label']) . '"/></td>
|
181 |
+
</tr>';
|
182 |
+
}
|
183 |
+
echo '</tbody></table>';
|
184 |
+
|
185 |
+
}
|
186 |
+
}
|
187 |
+
|
188 |
+
if( is_admin() ) {
|
189 |
+
$mic_settings_page = new MicSettingsPage();
|
190 |
}
|
manual-image-crop.php
CHANGED
@@ -3,13 +3,13 @@
|
|
3 |
Plugin Name: Manual Image Crop
|
4 |
Plugin URI: http://www.rocketmill.co.uk/wordpress-plugin-manual-image-crop
|
5 |
Description: Plugin allows you to manually crop all the image sizes registered in your WordPress theme (in particular featured image). Simply click on the "Crop" link next to any image in your media library and select the area of the image you want to crop.
|
6 |
-
Version: 1.
|
7 |
Author: Tomasz Sita
|
8 |
Author URI: http://www.rocketmill.co.uk/author/tomasz
|
9 |
License: GPL2
|
10 |
*/
|
11 |
|
12 |
-
define('mic_VERSION', '1.
|
13 |
|
14 |
|
15 |
include_once(dirname(__FILE__) . '/lib/ManualImageCrop.php');
|
3 |
Plugin Name: Manual Image Crop
|
4 |
Plugin URI: http://www.rocketmill.co.uk/wordpress-plugin-manual-image-crop
|
5 |
Description: Plugin allows you to manually crop all the image sizes registered in your WordPress theme (in particular featured image). Simply click on the "Crop" link next to any image in your media library and select the area of the image you want to crop.
|
6 |
+
Version: 1.07
|
7 |
Author: Tomasz Sita
|
8 |
Author URI: http://www.rocketmill.co.uk/author/tomasz
|
9 |
License: GPL2
|
10 |
*/
|
11 |
|
12 |
+
define('mic_VERSION', '1.07');
|
13 |
|
14 |
|
15 |
include_once(dirname(__FILE__) . '/lib/ManualImageCrop.php');
|
readme.txt
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
=== Manual Image Crop ===
|
2 |
Contributors: tomasz.sita
|
3 |
Tags: crop, cropping, thumbnail, featured image, gallery, images, picture, image, image area
|
4 |
-
Tested up to: 3.9.
|
5 |
Requires at least: 3.0.1
|
6 |
License: GPLv2 or later
|
7 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
8 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=WB5ZQWGUM7T96
|
9 |
-
Stable tag: 1.
|
10 |
|
11 |
Plugin allows you to manually crop all the image sizes registered in your WordPress theme (in particular featured image).
|
12 |
|
@@ -45,6 +45,9 @@ Automatically:
|
|
45 |
* When the plugin has been installed, Click 'Activate'
|
46 |
|
47 |
== Changelog ==
|
|
|
|
|
|
|
48 |
= 1.06 =
|
49 |
* French, German, Italian, Polish, Spanish translations added
|
50 |
* Settings page added (quality, visibility, custom labels)
|
1 |
=== Manual Image Crop ===
|
2 |
Contributors: tomasz.sita
|
3 |
Tags: crop, cropping, thumbnail, featured image, gallery, images, picture, image, image area
|
4 |
+
Tested up to: 3.9.2
|
5 |
Requires at least: 3.0.1
|
6 |
License: GPLv2 or later
|
7 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
8 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=WB5ZQWGUM7T96
|
9 |
+
Stable tag: 1.07
|
10 |
|
11 |
Plugin allows you to manually crop all the image sizes registered in your WordPress theme (in particular featured image).
|
12 |
|
45 |
* When the plugin has been installed, Click 'Activate'
|
46 |
|
47 |
== Changelog ==
|
48 |
+
= 1.07 =
|
49 |
+
* Fixed 'Cannot use string offset as an array' error
|
50 |
+
|
51 |
= 1.06 =
|
52 |
* French, German, Italian, Polish, Spanish translations added
|
53 |
* Settings page added (quality, visibility, custom labels)
|