Plugin Directory

Changeset 3407371


Ignore:
Timestamp:
12/01/2025 11:17:28 PM (4 months ago)
Author:
kubiq
Message:

3.9

  • tested on WP 6.9
  • new user role capability regenerate_images that allows users to regenerate images
Location:
better-image-sizes/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • better-image-sizes/trunk/better-image-sizes.php

    r3324341 r3407371  
    44    Plugin URI: https://wp-speedup.eu
    55    Description: Better image sizes
    6     Version: 3.8
     6    Version: 3.9
    77    Author: KubiQ
    88    Author URI: https://kubiq.sk
  • better-image-sizes/trunk/readme.txt

    r3324341 r3407371  
    22Contributors: kubiq
    33Donate link: https://www.paypal.me/jakubnovaksl
    4 Tags: images, media, thumbnails, sizes, retina, responsive, optimize
     4Tags: media, thumbnails, retina, responsive, optimize
    55Requires at least: 3.0.1
    66Requires PHP: 5.6
    7 Tested up to: 6.8
    8 Stable tag: 3.8
     7Tested up to: 6.9
     8Stable tag: 3.9
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    230230== Changelog ==
    231231
     232= 3.9 =
     233* tested on WP 6.9
     234* new user role capability regenerate_images that allows users to regenerate images
     235
    232236= 3.8 =
    233237* bis_get_attachment_picture function using $sizes argument with key 0 will replace <img> tag in <picture>
  • better-image-sizes/trunk/resizer/index.php

    r3324341 r3407371  
    7373                __( 'Better image sizes', 'bis-images' ),
    7474                __( 'Better image sizes', 'bis-images' ),
    75                 'manage_options',
     75                'read',
    7676                BIS_BASE,
    7777                array( $this, 'options_page' )
     
    103103        function options_page(){
    104104            if( isset( $_POST['bis_nonce'] ) && wp_verify_nonce( $_POST['bis_nonce'], 'delete_all_bis_images' ) ){
    105                 $this->delete_all_bis_images();
    106                 echo '<div class="updated"><p>' . esc_html__( 'All cached images have been deleted.', 'bis-images' ) . '</p></div>';
     105                if( current_user_can('manage_options') || current_user_can('regenerate_images') ){
     106                    $this->delete_all_bis_images();
     107                    echo '<div class="updated"><p>' . esc_html__( 'All cached images have been deleted.', 'bis-images' ) . '</p></div>';
     108                }
    107109            }elseif( isset( $_POST['bis_disabled_upscaling_nonce'] ) && wp_verify_nonce( $_POST['bis_disabled_upscaling_nonce'], 'disabled_upscaling' ) ){
    108                 update_option( 'bis_disabled_upscaling', intval( $_POST['bis_disabled_upscaling'] ) );
    109                 echo '<div class="updated"><p>' . esc_html__( 'Disable upscaling updated.', 'bis-images' ) . '</p></div>';
     110                if( current_user_can('manage_options') ){
     111                    update_option( 'bis_disabled_upscaling', intval( $_POST['bis_disabled_upscaling'] ) );
     112                    echo '<div class="updated"><p>' . esc_html__( 'Disable upscaling updated.', 'bis-images' ) . '</p></div>';
     113                }
    110114            }elseif( isset( $_POST['bis_disabled_sizes_nonce'] ) && wp_verify_nonce( $_POST['bis_disabled_sizes_nonce'], 'disabled_sizes' ) ){
    111                 $sizes = $this->get_all_image_sizes();
    112                 $bis_disabled_sizes = array();
    113                 foreach( $_POST['bis_disabled_sizes'] as $key => $value ){
    114                     if( isset( $sizes[ $key ] ) ){
    115                         $bis_disabled_sizes[ $key ] = intval( $value );
    116                     }
    117                 }
    118                 update_option( 'bis_disabled_sizes', $bis_disabled_sizes );
    119                 echo '<div class="updated"><p>' . esc_html__( 'Disable autogenerated sizes updated.', 'bis-images' ) . '</p></div>';
     115                if( current_user_can('manage_options') ){
     116                    $sizes = $this->get_all_image_sizes();
     117                    $bis_disabled_sizes = array();
     118                    foreach( $_POST['bis_disabled_sizes'] as $key => $value ){
     119                        if( isset( $sizes[ $key ] ) ){
     120                            $bis_disabled_sizes[ $key ] = intval( $value );
     121                        }
     122                    }
     123                    update_option( 'bis_disabled_sizes', $bis_disabled_sizes );
     124                    echo '<div class="updated"><p>' . esc_html__( 'Disable autogenerated sizes updated.', 'bis-images' ) . '</p></div>';
     125                }
    120126            }elseif( isset( $_POST['bis_disable_threshold_nonce'] ) && wp_verify_nonce( $_POST['bis_disable_threshold_nonce'], 'disable_threshold' ) ){
    121                 $disable_threshold = 0;
    122                 if( isset( $_POST['bis_disable_big_image_size_threshold'] ) ){
    123                     $disable_threshold = intval( $_POST['bis_disable_big_image_size_threshold'] );
    124                 }
    125                 update_option( 'bis_disable_big_image_size_threshold', $disable_threshold ? 1 : 0 );
    126                 echo '<div class="updated"><p>' . esc_html__( 'Big image threshold updated.', 'bis-images' ) . '</p></div>';
     127                if( current_user_can('manage_options') ){
     128                    $disable_threshold = 0;
     129                    if( isset( $_POST['bis_disable_big_image_size_threshold'] ) ){
     130                        $disable_threshold = intval( $_POST['bis_disable_big_image_size_threshold'] );
     131                    }
     132                    update_option( 'bis_disable_big_image_size_threshold', $disable_threshold ? 1 : 0 );
     133                    echo '<div class="updated"><p>' . esc_html__( 'Big image threshold updated.', 'bis-images' ) . '</p></div>';
     134                }
    127135            }elseif( isset( $_GET['delete-bis-image'], $_GET['ids'], $_GET['bis_nonce'] ) && wp_verify_nonce( $_GET['bis_nonce'], 'delete_bis_image' ) ){
    128                 $ids = array_map( 'intval', array_map( 'trim', explode( ',', sanitize_key( $_GET['ids'] ) ) ) );
    129                 if( ! empty( $ids ) ){
    130                     foreach( $ids as $id ){
    131                         $this->delete_attachment_bis_images( $id );
    132                     }
    133                     echo '<div class="updated"><p>' . esc_html__( 'All cached images for this media file have been deleted.', 'bis-images' ) . '</p></div>';
    134                 }
    135             } ?>
    136 
    137             <div class="wrap">
    138                 <h2>Better image sizes</h2>
    139 
    140                 <div class="card">
    141                     <h3><?php esc_html_e( 'Images directory', 'bis-images' ); ?></h3>
    142                     <p><code><?php echo esc_html( $this->get_bis_dir() ) ?></code></p>
    143                     <?php if( $this->bis_dir_writable() ): ?>
    144                         <p style="color:#7AD03A"><?php esc_html_e( 'Writeable', 'bis-images' ) ?></p>
    145                     <?php else: ?>
    146                         <p style="color:#A00"><?php esc_html_e( 'Not Writeable - please make sure this folder exists and is writeable!', 'bis-images' ) ?></p>
    147                     <?php endif ?>
    148                 </div>
    149 
    150                 <div class="card">
    151                     <h3><?php esc_html_e( 'Disable upscaling images', 'bis-images' ) ?></h3>
    152                     <form method="post" action=""><?php
    153                         wp_nonce_field( 'disabled_upscaling', 'bis_disabled_upscaling_nonce' );
    154                         $bis_disabled_upscaling = get_option( 'bis_disabled_upscaling', 1 ); ?>
    155                         <input type="hidden" name="bis_disabled_upscaling" value="0">
    156                         <label>
    157                             <input type="checkbox" name="bis_disabled_upscaling" value="1" <?php checked( $bis_disabled_upscaling, 1 ) ?>>
    158                             <?php esc_html_e( 'return the full original image if it is smaller than the requested size', 'bis-images' ) ?>
    159                         </label><br>
    160                         <br><input class="button button-primary" value="<?php esc_html_e( 'Save', 'bis-images' ) ?>" type="submit">
    161                     </form>
    162                 </div>
    163 
    164                 <div class="card">
    165                     <h3><?php esc_html_e( 'Disable autogenerated sizes', 'bis-images' ) ?></h3>
    166                     <p class="notice notice-info notice-large">
    167                         <?php esc_html_e( 'You should not disable thumbnail size', 'bis-images' ); ?>
    168                     </p>
    169                     <form method="post" action=""><?php
    170                         wp_nonce_field( 'disabled_sizes', 'bis_disabled_sizes_nonce' );
    171                         $bis_disabled_sizes = get_option( 'bis_disabled_sizes', array() );
    172                         $sizes = $this->get_all_image_sizes();
    173                         foreach( $sizes as $size => $data ){
    174                             if( ! isset( $bis_disabled_sizes[ $size ] ) ){
    175                                 $bis_disabled_sizes[ $size ] = 0;
     136                if( current_user_can('manage_options') || current_user_can('regenerate_images') ){
     137                    $ids = array_map( 'intval', array_map( 'trim', explode( ',', sanitize_key( $_GET['ids'] ) ) ) );
     138                    if( ! empty( $ids ) ){
     139                        foreach( $ids as $id ){
     140                            $this->delete_attachment_bis_images( $id );
     141                        }
     142                        echo '<div class="updated"><p>' . esc_html__( 'All cached images for this media file have been deleted.', 'bis-images' ) . '</p></div>';
     143                    }
     144                }
     145            }
     146
     147            if( current_user_can('manage_options') ){ ?>
     148                <div class="wrap">
     149                    <h2>Better image sizes</h2>
     150
     151                    <div class="card">
     152                        <h3><?php esc_html_e( 'Images directory', 'bis-images' ); ?></h3>
     153                        <p><code><?php echo esc_html( $this->get_bis_dir() ) ?></code></p>
     154                        <?php if( $this->bis_dir_writable() ): ?>
     155                            <p style="color:#7AD03A"><?php esc_html_e( 'Writeable', 'bis-images' ) ?></p>
     156                        <?php else: ?>
     157                            <p style="color:#A00"><?php esc_html_e( 'Not Writeable - please make sure this folder exists and is writeable!', 'bis-images' ) ?></p>
     158                        <?php endif ?>
     159                    </div>
     160
     161                    <div class="card">
     162                        <h3><?php esc_html_e( 'Disable upscaling images', 'bis-images' ) ?></h3>
     163                        <form method="post" action=""><?php
     164                            wp_nonce_field( 'disabled_upscaling', 'bis_disabled_upscaling_nonce' );
     165                            $bis_disabled_upscaling = get_option( 'bis_disabled_upscaling', 1 ); ?>
     166                            <input type="hidden" name="bis_disabled_upscaling" value="0">
     167                            <label>
     168                                <input type="checkbox" name="bis_disabled_upscaling" value="1" <?php checked( $bis_disabled_upscaling, 1 ) ?>>
     169                                <?php esc_html_e( 'return the full original image if it is smaller than the requested size', 'bis-images' ) ?>
     170                            </label><br>
     171                            <br><input class="button button-primary" value="<?php esc_html_e( 'Save', 'bis-images' ) ?>" type="submit">
     172                        </form>
     173                    </div>
     174
     175                    <div class="card">
     176                        <h3><?php esc_html_e( 'Disable autogenerated sizes', 'bis-images' ) ?></h3>
     177                        <p class="notice notice-info notice-large">
     178                            <?php esc_html_e( 'You should not disable thumbnail size', 'bis-images' ); ?>
     179                        </p>
     180                        <form method="post" action=""><?php
     181                            wp_nonce_field( 'disabled_sizes', 'bis_disabled_sizes_nonce' );
     182                            $bis_disabled_sizes = get_option( 'bis_disabled_sizes', array() );
     183                            $sizes = $this->get_all_image_sizes();
     184                            foreach( $sizes as $size => $data ){
     185                                if( ! isset( $bis_disabled_sizes[ $size ] ) ){
     186                                    $bis_disabled_sizes[ $size ] = 0;
     187                                } ?>
     188                                <label>
     189                                    <input type="checkbox" name="bis_disabled_sizes[<?php echo esc_attr( $size ) ?>]" value="1" <?php checked( $bis_disabled_sizes[ $size ], 1 ) ?>>
     190                                    <?php echo esc_html( $size ) ?> <small>(<?php echo esc_html( $data['w'] . 'x' . $data['h'] ) ?>)</small>
     191                                </label><br><?php
    176192                            } ?>
     193                            <br><input class="button button-primary" value="<?php esc_html_e( 'Save', 'bis-images' ) ?>" type="submit">
     194                        </form>
     195                    </div>
     196
     197                    <div class="card">
     198                        <h3><?php esc_html_e( 'Disable big image size threshold', 'bis-images' ) ?></h3>
     199                        <p><?php esc_html_e( 'WordPress will automatically scale down your uploaded images, if the original image width or height is above 2560px', 'bis-images' ) ?></p>
     200                        <form method="post" action="">
     201                            <?php wp_nonce_field( 'disable_threshold', 'bis_disable_threshold_nonce' ) ?>
    177202                            <label>
    178                                 <input type="checkbox" name="bis_disabled_sizes[<?php echo esc_attr( $size ) ?>]" value="1" <?php checked( $bis_disabled_sizes[ $size ], 1 ) ?>>
    179                                 <?php echo esc_html( $size ) ?> <small>(<?php echo esc_html( $data['w'] . 'x' . $data['h'] ) ?>)</small>
    180                             </label><br><?php
    181                         } ?>
    182                         <br><input class="button button-primary" value="<?php esc_html_e( 'Save', 'bis-images' ) ?>" type="submit">
    183                     </form>
    184                 </div>
    185 
    186                 <div class="card">
    187                     <h3><?php esc_html_e( 'Disable big image size threshold', 'bis-images' ) ?></h3>
    188                     <p><?php esc_html_e( 'WordPress will automatically scale down your uploaded images, if the original image width or height is above 2560px', 'bis-images' ) ?></p>
    189                     <form method="post" action="">
    190                         <?php wp_nonce_field( 'disable_threshold', 'bis_disable_threshold_nonce' ) ?>
    191                         <label>
    192                             <input type="checkbox" name="bis_disable_big_image_size_threshold" value="1" <?php checked( get_option( 'bis_disable_big_image_size_threshold', 0 ), 1 ) ?>>
    193                             <?php esc_html_e( 'disable auto-scaling of big images', 'bis-images' ) ?>
    194                         </label><br><br>
    195                         <input class="button button-primary" value="<?php esc_html_e( 'Save', 'bis-images' ) ?>" type="submit">
    196                     </form>
    197                 </div>
    198 
    199                 <div class="card">
    200                     <h3><?php esc_html_e( 'Delete cached images', 'bis-images' ) ?></h3>
    201                     <p><?php esc_html_e( 'Delete all generated image sizes for all images', 'bis-images' ) ?></p>
    202                     <p><small><?php esc_html_e( '* they will be regenerated instantly when you visit your website', 'bis-images' ) ?></small></p>
    203                     <br>
    204                     <form method="post" action="">
    205                         <?php wp_nonce_field( 'delete_all_bis_images', 'bis_nonce' ) ?>
    206                         <input class="button button-primary" value="<?php esc_html_e( 'Delete all', 'bis-images' ) ?>" type="submit">
    207                     </form>
    208                 </div>
    209             </div><?php
     203                                <input type="checkbox" name="bis_disable_big_image_size_threshold" value="1" <?php checked( get_option( 'bis_disable_big_image_size_threshold', 0 ), 1 ) ?>>
     204                                <?php esc_html_e( 'disable auto-scaling of big images', 'bis-images' ) ?>
     205                            </label><br><br>
     206                            <input class="button button-primary" value="<?php esc_html_e( 'Save', 'bis-images' ) ?>" type="submit">
     207                        </form>
     208                    </div>
     209
     210                    <div class="card">
     211                        <h3><?php esc_html_e( 'Delete cached images', 'bis-images' ) ?></h3>
     212                        <p><?php esc_html_e( 'Delete all generated image sizes for all images', 'bis-images' ) ?></p>
     213                        <p><small><?php esc_html_e( '* they will be regenerated instantly when you visit your website', 'bis-images' ) ?></small></p>
     214                        <br>
     215                        <form method="post" action="">
     216                            <?php wp_nonce_field( 'delete_all_bis_images', 'bis_nonce' ) ?>
     217                            <input class="button button-primary" value="<?php esc_html_e( 'Delete all', 'bis-images' ) ?>" type="submit">
     218                        </form>
     219                    </div>
     220                </div><?php
     221            }
    210222        }
    211223
Note: See TracChangeset for help on using the changeset viewer.