' . 'Settings' . ''; return $links; } /** * Adds a link to the adaptive images settings in the plugins listing page for convenience. * * @author Nevma (info@nevma.gr) * * @param array $links The plugin links array in the plugins listing page. * * @return void */ function adaptive_images_admin_add_row_meta ( $links, $file ) { if ( $file != adaptive_images_plugin_get_name() ) { return $links; } $links[] = '' . 'Plugin page' . ''; $links[] = '' . 'Plugin support page' . ''; return $links; } /** * Adds the plugin settings page to the admin area. * * @author Nevma (info@nevma.gr) * * @return void */ function adaptive_images_admin_add_options_page () { // Adds the plugin's options page as a submenu of the admin settings. $hook_name = add_options_page( 'Adaptive Images', // page title 'Adaptive Images', // menu title 'manage_options', // capability 'adaptive-images', // menu slug 'adaptive_images_admin_options_page_print' // print function callback ); // Adds the action which adds the plugin admin actions. add_action( 'admin_head-' . $hook_name, 'adaptive_images_admin_settings_actions' ); } /** * Registers the plugin settings. * * @author Nevma (info@nevma.gr) * * @return void */ function adaptive_images_admin_register_settings () { // Registers the plugin settings field. register_setting( 'adaptive-images-settings', // option group 'adaptive-images', // option name 'adaptive_images_admin_settings_sanitize' // function validator callback ); // Adds the plugin main settings section. add_settings_section( 'adaptive-images-settings', // id '', // title '', // print function callback 'adaptive-images' // plugin page ); // Adds the adaptive images resolutions field. add_settings_field( 'resolutions', // id 'Resolutions', // title 'adaptive_images_admin_resolutions_field_print', // print function callback 'adaptive-images', // plugin page 'adaptive-images-settings' // section ); // Adds the adaptive images landscape field. add_settings_field( 'orientation', // id 'Bigger dimension', // title 'adaptive_images_admin_landscape_field_print', // print function callback 'adaptive-images', // plugin page 'adaptive-images-settings' // section ); // Adds the adaptive images hidpi field. add_settings_field( 'hidpi', // id 'HiDPI support', // title 'adaptive_images_admin_hidpi_field_print', // print function callback 'adaptive-images', // plugin page 'adaptive-images-settings' // section ); // Adds the adaptive images CDN support field. add_settings_field( 'cdn-support', // id 'CDN support', // title 'adaptive_images_admin_cdn_support_field_print', // print function callback 'adaptive-images', // plugin page 'adaptive-images-settings' // section ); // Adds the adaptive images cache directory field. add_settings_field( 'cache-directory', // id 'Cache directory', // title 'adaptive_images_admin_cache_directory_field_print', // print function callback 'adaptive-images', // plugin page 'adaptive-images-settings' // section ); // Adds the adaptive images watched directories field. add_settings_field( 'watched-directories', // id 'Watched directories', // title 'adaptive_images_admin_watched_directories_field_print', // print function callback 'adaptive-images', // plugin page 'adaptive-images-settings' // section ); // Adds the adaptive images JPEG quality field. add_settings_field( 'jpeg-quality', // id 'JPEG quality', // title 'adaptive_images_admin_jpeg_quality_field_print', // print function callback 'adaptive-images', // plugin page 'adaptive-images-settings' // section ); // Adds the adaptive images sharpen field. add_settings_field( 'sharpen-images', // id 'Sharpen images', // title 'adaptive_images_admin_sharpen_images_field_print', // print function callback 'adaptive-images', // plugin page 'adaptive-images-settings' // section ); // Adds the adaptive images watch cache (for stale images) field. add_settings_field( 'watch-cache', // id 'Watch cache', // title 'adaptive_images_admin_watch_cache_field_print', // print function callback 'adaptive-images', // plugin page 'adaptive-images-settings' // section ); // Adds the adaptive images browser cache duration field. add_settings_field( 'browser-cache', // id 'Browser cache', // title 'adaptive_images_admin_browser_cache_field_print', // print function callback 'adaptive-images', // plugin page 'adaptive-images-settings' // section ); } /** * Prints the resolutions settings field. * * @author Nevma (info@nevma.gr) * * @return void */ function adaptive_images_admin_resolutions_field_print () { $options = get_option( 'adaptive-images' ); adaptive_images_plugin_check_empty_setting( $options, 'resolutions' ); ?> A comma separated list of device widths. Directory inside /wp-content to store the image cache.
Current path on server: .
Directories to watch for images to resize for mobile devices. Has to be relative paths inside your WordPress installation. Compression level of JPEG images, 100 means best quality but biggest file size.
Usuallly a 60 to 70 JPEG compression level works fine for the human eye and achieves very small file sizes. How long should browsers be instructed to cache images.
Unless you have a very special need and/or you know what you are doing, set this to as high a value as you can.

Adaptive Images Settings


Image Cache Tools

Calculate total cache size.

Calculate size
(might take some time)
Cleanup the image cache.

Cleanup cache
(might take some time)

Debugging Tools

Print debug information.

Print debug info
(this is quite quick)
Print diagnostic information.

Print diagnostics
(this is quite quick)

Contact the developers

Thank you so much for trying out the "Adaptive Images for WordPress" plugin.
Please, do not hesitate to report any problems and send us your suggestions at the plugin support page.
We will really appreciate it!

Many-many thanks,
Nevma, the development team!


Show us your love

🌟🌟🌟🌟🌟
We do appreciate an honest review and rating!

👍👍👍👍👍
State that the plugin actually works by clicking here!


Should you wish to buy us a beer, we prefer weiss!


Adaptive Images v.

' . '

Total files deleted from the adaptive images cache: ' . $result['files'] . '

' . '

Total directories deleted from the adaptive images cache: ' . $result['dirs'] . '

' . '

' . 'Total size deleted from the adaptive images cache: ' . adaptive_images_plugin_file_size_human( $result['size'] ) . '

', 'updated' ); } // Calculate image cache size action. if ( $_GET['action'] == 'calculate-cache-size' && wp_verify_nonce( $_GET['_wpnonce'], 'adaptive-images-calculate-cache-size' ) ) { $cache_path = adaptive_images_plugin_get_cahe_directory_path(); $cache_size = adaptive_images_plugin_dir_size( $cache_path ); add_settings_error( 'adaptive-images-settings', 'adaptive-images-settings-error', 'Calculate cache size
' . '

Total files in the adaptive images cache: ' . $cache_size['files'] . '

' . '

Total directories in the adaptive images cache: ' . $cache_size['dirs'] . '

' . '

' . 'Total size of the adaptive images cache: ' . adaptive_images_plugin_file_size_human( $cache_size['size'] ) . '

', 'updated' ); } // Print plugin info action. if ( $_GET['action'] == 'print-debug-info' && wp_verify_nonce( $_GET['_wpnonce'], 'adaptive-images-print-debug-info' ) ) { add_settings_error( 'adaptive-images-settings', 'adaptive-images-settings-error', 'Debug info
' . adaptive_images_debug_general_info( FALSE ), 'updated' ); } // Print system info action. if ( $_GET['action'] == 'print-diagnostic-info' && wp_verify_nonce( $_GET['_wpnonce'], 'adaptive-images-print-diagnostic-info' ) ) { add_settings_error( 'adaptive-images-settings', 'adaptive-images-settings-error', 'System information
' . adaptive_images_debug_diagnostic_info( FALSE ), 'updated' ); } } /** * Validates the adaptive images submitted settings. * * @author Nevma (info@nevma.gr) * * @return The sanitized and validated data. */ function adaptive_images_admin_settings_sanitize ( $data ) { // To avoid the bug of sanitizing twice the first time the option is created. if ( isset( $data['sanitized'] ) && $data['sanitized'] ) { return $data; } // Get the defaults just in case. $defaults = adaptive_images_plugin_get_default_settings(); // Resolutions field array validation. $resolutions = trim( $data['resolutions'] ); $resolutions_array = explode( ',', $resolutions ); $resolutions_array_sanitized = array(); for ( $k = 0, $length = count( $resolutions_array ); $k < $length; $k++ ) { $resolution = trim( $resolutions_array[$k] ); $resolution = intval( $resolution ); if ( $resolution > 0 ) { $resolutions_array_sanitized[] = $resolution; } } rsort( $resolutions_array_sanitized ); if ( count( $resolutions_array_sanitized ) == 0 ) { $resolutions_array_sanitized = $defaults['resolutions']; } $data['resolutions'] = $resolutions_array_sanitized; adaptive_images_plugin_check_empty_setting( $data, 'resolutions' ); // Landscape field validation. $landscape = isset( $data['landscape'] ) && $data['landscape'] == 'on' ? TRUE : FALSE; $data['landscape'] = $landscape; adaptive_images_plugin_check_empty_setting( $data, 'landscape' ); // Hidpi field validation. $hidpi = isset( $data['hidpi'] ) && $data['hidpi'] == 'on' ? TRUE : FALSE; $data['hidpi'] = $hidpi; adaptive_images_plugin_check_empty_setting( $data, 'hidpi' ); // CDN support field validation. $cdn_support = isset( $data['cdn-support'] ) && $data['cdn-support'] == 'on' ? TRUE : FALSE; $data['cdn-support'] = $cdn_support; adaptive_images_plugin_check_empty_setting( $data, 'cdn-support' ); // Cache field directory validation. $cache_directory = trim( $data['cache-directory'] ); $cache_directory = preg_replace( '/[^a-zA-Z\d-_\/]+/i', '', $cache_directory ); $cache_directory = wp_normalize_path( $cache_directory ); $cache_directory = untrailingslashit( $cache_directory ); if ( ! adaptive_images_plugin_is_file_in_wp_content( $cache_directory ) ) { $cache_directory == $defaults['cache-directory']; } $data['cache-directory'] = $cache_directory; adaptive_images_plugin_check_empty_setting( $data, 'cache-directory' ); // Watched field directories validation. $watched_directories_string = trim( $data['watched-directories'] ); $watched_directories_array = explode( "\n", $watched_directories_string ); $watched_directories_array_sanitized = array(); foreach ( $watched_directories_array as $directory ) { $directory = preg_replace( '/[^a-zA-Z\d-_\/]+/i', '', $directory ); $directory = wp_normalize_path( $directory ); $directory = untrailingslashit( $directory ); if ( $directory ) { $watched_directories_array_sanitized[] = $directory; } } $data['watched-directories'] = $watched_directories_array_sanitized; adaptive_images_plugin_check_empty_setting( $data, 'watched-directories' ); // JPEG quality field validation. $jpeg_quality = intval( $data['jpeg-quality'] ); if ( $jpeg_quality == 0 ) { $jpeg_quality = $defaults['jpeg-quality']; } $data['jpeg-quality'] = $jpeg_quality; adaptive_images_plugin_check_empty_setting( $data, 'jpeg-quality' ); // Sharpen field validation. $sharpen_images = isset( $data['sharpen-images'] ) && $data['sharpen-images'] == 'on' ? TRUE : FALSE; $data['sharpen-images'] = $sharpen_images; adaptive_images_plugin_check_empty_setting( $data, 'sharpen-images' ); // Watch cache field validation. $watch_cache = isset( $data['watch-cache'] ) && $data['watch-cache'] == 'on' ? TRUE : FALSE; $data['watch-cache'] = $watch_cache; adaptive_images_plugin_check_empty_setting( $data, 'watch-cache' ); // Browser cache field validation. $browser_cache = floatval( $data['browser-cache'] ); if ( $browser_cache < 0 ) { $browser_cache = $defaults['browser-cache']; } $data['browser-cache'] = $browser_cache; adaptive_images_plugin_check_empty_setting( $data, 'browser-cache' ); // Save plugin version. $data['version'] = adaptive_images_plugin_get_version(); // To avoid the bug of sanitizing twice the first time the option is created. $data['sanitized'] = TRUE; // Notify user appropriately. $message = 'Adaptive Images — Settings updated.

The settings have been saved in the database.

'; // Add the adaptive images .htaccess rewrite block. $result = adaptive_images_actions_update_htaccess( $data ); if ( is_wp_error( $result ) ) { $error_data = $result->get_error_data(); $htaccess = $error_data['htaccess']; $permissions = adaptive_images_plugin_file_permissions( $htaccess ); $message .= '

' . $result->get_error_message() . ' ' . 'This probably means a filesystem error or a permissions problem: ' . '' . $htaccess . ' => ' . $permissions . '.' . '

' . '

' . 'Consider adding this code to your .htaccess file manually: ' . '

' . htmlspecialchars( trim( $error_data['rewrite'] ) ) . '
' . '

'; } else { $message .= '

' . 'The .htaccess file was successfully updated: ' . '' . adaptive_images_plugin_get_htaccess_file_path() . '.' . '

'; } // Save user settings PHP file. $result = adaptive_images_actions_save_user_settings( $data ); if ( is_wp_error( $result ) ) { $file = adaptive_images_plugin_get_user_settings_file_path(); $permissions = adaptive_images_plugin_file_permissions( $file ); $message .= '

' . $result->get_error_message() . ' ' . 'This probably means a filesystem error or a permissions problem.' . '' . $file . ' => ' . $permissions . '.
'. '

' . '

' . 'The plugin will still be able to function but with its default settings until this problem is resolved.' . '

'; } else { $message .= '

' . 'The user settings PHP file was successfully updated: ' . '' . adaptive_images_plugin_get_user_settings_file_path() . '.' . '

'; } // Inform user accordingly. add_settings_error( 'adaptive-images-settings', 'adaptive-images-settings-error', $message, 'updated' ); return $data; } ?>