You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Callback function that outputs the content for the menu page.
159
+
*
160
+
* @since 3.2.0
161
+
* @access private
162
+
* @see '_tevkori_add_menu_page()'
163
+
*/
164
+
function_tevkori_menu_page() {
165
+
global$wp_version;
166
+
167
+
$matches = _tevkori_find_respimg_attr();
168
+
?>
169
+
<div class="wrap">
170
+
<h2>RICG Responsive Images Plugin</h2>
171
+
172
+
<div class="notice notice-warning">
173
+
<p>We have found <?phpif ( 1 == $matches ) { echo'1 post'; } else { echo$matches . ' posts'; } ?> with images that contain <code>data-sizes</code> and <code>srcset</code> attributes. We strongly recommend to remove those attributes from images in your posts.</p>
174
+
</div>
175
+
176
+
<h3>Explanation</h3>
177
+
178
+
<p>To make an image responsive the <code>img</code> element needs to have a <code>srcset</code> and <code>sizes</code> attribute. Prior to version 2.5, this plugin added a <code>srcset</code> and <code>data-sizes</code> attribute while inserting the image in the content and replaced <code>data-sizes</code> by <code>sizes</code> before a post was being displayed. Since version 2.5 those attributes are no longer added while inserting an image in the content. Instead, both <code>srcset</code> and <code>sizes</code> are added to images by using a filter before a post is being displayed, but <em>not</em> if an image already has a <code>srcset</code> attribute.</p>
179
+
180
+
<p>The plugin still replaces <code>data-sizes</code> by <code>sizes</code> to make sure that images that have been inserted while version 2.4 or older was active have both the <code>srcset</code> and <code>sizes</code> attribute. However, after deactivating the plugin those images won't get a <code>sizes</code> attribute anymore while they do have a <code>srcset</code>. This is <strong>invalid markup</strong> and results in images being displayed at a <strong>wrong size</strong>!</p>
181
+
182
+
<p>Besides this, the functions that calculate the values for the <code>srcset</code> and <code>sizes</code> attributes have been improved over time and filter hooks have been added to make it possible to change the values in specific situations. As long as images already have a <code>srcset</code> attribute you won't benefit from these improvements.</p>
183
+
184
+
<p>Therefor it's strongly recommended to remove <code>data-sizes</code> and <code>srcset</code> attributes from <code>img</code> elements in the post content. You can do this automatically with the cleanup tool on this page or manually.</p>
185
+
186
+
<?phpif ( $wp_version >= 4.4 ) : ?>
187
+
<h4>WordPress 4.4+</h4>
188
+
189
+
<p>As from WordPress 4.4 the <code>srcset</code> and <code>sizes</code> attributes are added by WordPress itself. This is done in exactly the same way as it was done by this plugin, meaning that no attributes are added if an image already has a <code>srcset</code> attribute.</p>
190
+
191
+
<h4>Do I Still Need This Plugin After Removing The Attributes?</h4>
192
+
193
+
<p>No, you would no longer need to use this plugin to make images responsive if the <code>data-sizes</code> and <code>srcset</code> attributes have been removed from all images. However, you can keep using it to benefit from the following two features:</p>
194
+
195
+
<ol>
196
+
<li>The plugin loads the Picturefill polyfill, a small JavaScript file that makes responsive images work on older browsers that don't offer native support</li>
197
+
<li>Advanced image compression (via opt-in)</li>
198
+
</ol>
199
+
200
+
<p>See the <a href="https://wordpress.org/plugins/ricg-responsive-images/">plugin page</a> and the <a href="https://github.com/ResponsiveImagesCG/wp-tevko-responsive-images#documentation">plugin documentation</a> for more information.</p>
201
+
<?phpendif; ?>
202
+
203
+
<h3>Cleanup Tool</h3>
204
+
205
+
<p>This tool automatically removes <code>data-sizes</code> and <code>srcset</code> attributes from all images in the content of your posts. It updates the post content in the database. This can't be undone and if something goes wrong you might lose your content so it's very important to <strong>make a backup of your database</strong> before proceeding!</p>
206
+
207
+
<p>After succesfully removing these attributes from all images this page will disappear from the Tools menu and you will no longer see a warning on the dashboard and plugin menu page.</p>
<p>To manually remove the <code>data-sizes</code> and <code>srcset</code> attributes you have to edit each post and page that contains images that were inserted while version 2.4 or older of this plugin was active. In the editor switch from the "Visual" to "Text" tab in the top right corner in order to see image markup instead of the images itself. Look for <code><img ... ></code> elements and delete <code>data-sizes="..."</code> and <code>srcset="..."</code>.</p>
222
+
223
+
<p>After you have removed these attributes from all images you can run this check. If there are no more images with these attributes this page will disappear from the Tools menu and you will no longer see a warning on the dashboard and plugin menu page.</p>
<p>If you have any questions, please post a message on the <a href="https://wordpress.org/support/plugin/ricg-responsive-images">support forum</a> of this plugin.</p>
234
+
</div>
235
+
<?php
236
+
}
237
+
238
+
/**
239
+
* Removes 'data-sizes' and 'srcset' attributes from image elements in the post content.
echo'<div class="notice notice-success is-dismissible"><p>Done! All <code>data-sizes</code> and <code>srcset</code> attributes have been succesfully removed from your images!</p></div>';
echo'<div class="notice notice-error is-dismissible"><p>Check finished. Not all <code>data-sizes</code> and <code>srcset</code> attributes have been removed yet!</p></div>';
341
+
} elseif ( 'backup' == $notice ) {
342
+
echo'<div class="notice notice-warning is-dismissible"><p>Please make a backup of your database before using the cleanup tool!</p></div>';
343
+
} elseif ( 'error' == $notice ) {
344
+
echo'<div class="notice notice-error is-dismissible"><p>Something went wrong! We recommend to check your posts if something is broken, revert to the backup of your database if necessary, and remove the <code>data-sizes</code> and <code>srcset</code> attributes manually.</p></div>';
0 commit comments