Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New helpers added #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion _imagify-helper-plugin/imagify-helper-plugin.php
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
* License: GNU General Public License v2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*
* Copyright SAS WP MEDIA 2018
* Copyright SAS WP MEDIA 2020
*/

// EDIT THIS: Replace `boilerplate` with your custom subnamespace.
Binary file added debugging/.DS_Store
Binary file not shown.
Binary file added debugging/imagify-tools-1.1.2.zip
Binary file not shown.
Binary file added optimization/.DS_Store
Binary file not shown.
Binary file added optimization/dont-use-imagick/.DS_Store
Binary file not shown.
23 changes: 23 additions & 0 deletions optimization/dont-use-imagick/dont-use-imagick.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
/**
* Plugin Name: Don’t use ImageMagick
* Description: Don't use the ImageMagick library to manipulate images (poor performances).
* Version: 1.0
* Author: WP Media
* Author URI: https://wp-media.me/
* Licence: GPLv2
*
* Copyright SAS WP MEDIA 2020
*/

defined( 'ABSPATH' ) || die( 'Cheatin\' uh?' );

add_filter( 'wp_image_editors', function( $editors ) {
$editors = array_diff(
$editors,
[ 'WP_Image_Editor_Imagick' ]
);
$editors[] = 'WP_Image_Editor_Imagick';

return $editors;
} );
Binary file not shown.
Binary file not shown.
43 changes: 17 additions & 26 deletions optimization/imagify-bulk-buffer-size/imagify-bulk-buffer-size.php
Original file line number Diff line number Diff line change
@@ -1,32 +1,23 @@
<?php
/**
* Plugin Name: Imagify | Change Bulk Buffer Size
* Description: Helps to avoid CPU issues during bulk optimization.
* Plugin URI: https://github.com/wp-media/imagify-helpers/tree/master/optimization/imagify-bulk-buffer-size/
* Author: Imagify Support Team
* Author URI: http://imagify.io/
* License: GNU General Public License v2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
* Plugin Name: Imagify bulk optimization buffer size
* Description: In Imagify’s bulk optimization, set the number of parallel optimizations to 1 for all contexts.
* Version: 1.0
* Author: WP Media
* Author URI: https://wp-media.me/
* Licence: GPLv2
*
* Copyright SAS WP MEDIA 2018
* Copyright SAS WP MEDIA 2020
*/
namespace ImagifyPlugin\Helpers\optimization\bulk;

defined( 'ABSPATH' ) or die();
defined( 'ABSPATH' ) || die( 'Cheatin\' uh?' );

add_filter( 'imagify_bulk_buffer_sizes', __NAMESPACE__ . '\buffer_sizes', 10, 3 );
/**
* Prevent automatic optimization for PDF.
*
* @author Grégory Viguier
* @author Caspar Hübinger
*
* @param array $buffer_sizes An array of number of parallel queries
* @return array Modified array
*/
function buffer_sizes( $buffer_sizes ) {

$buffer = array_keys( $buffer_sizes );

return array_fill_keys( $buffer_sizes, 1 );
}
add_filter(
'imagify_bulk_buffer_sizes',
function ( $buffer_sizes ) {
if ( ! $buffer_sizes || ! is_array( $buffer_sizes ) ) {
return [];
}
return array_fill_keys( array_keys( $buffer_sizes ), 1 );
}
);
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
* License: GNU General Public License v2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*
* Copyright SAS WP MEDIA 2018
* Copyright SAS WP MEDIA 2020
*/
namespace ImagifyPlugin\Helpers\optimization\auto;

Binary file added optimization/imagify-remove-thumbs/.DS_Store
Binary file not shown.
10 changes: 6 additions & 4 deletions optimization/imagify-remove-thumbs/imagify-remove-thumbs.php
Original file line number Diff line number Diff line change
@@ -3,28 +3,30 @@
* Plugin Name: Imagify helper - Remove image sizes 1536&2048px
* Plugin URI: https://wordpress.org/plugins/imagify/
* Description: A WordPress plugin that removes specific thumbnail sizes.
* Version: 1.0
* Version: 1.1
* Author: WP Media
* Author URI: https://wp-media.me/
* Licence: GPLv2
*
* Text Domain: imagify-remove-thumbs
*
* Copyright 2019 WP Media
* Copyright SAS WP MEDIA 2020
*/

defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' );

add_filter( 'big_image_size_threshold', '__return_false' );

function remove_default_image_sizes( $sizes) {
unset( $sizes['1536x1536']);
unset( $sizes['1536x1536']);
unset( $sizes['2048x2048']);
return $sizes;
}

add_filter('intermediate_image_sizes_advanced', 'remove_default_image_sizes');

function remove_images_sizes() {
remove_image_size( '1536x1536' );
remove_image_size( '1536x1536' );
remove_image_size( '2048x2048' );
}
add_action('init', 'remove_images_sizes');
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
* License: GNU General Public License v2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*
* Copyright SAS WP MEDIA 2018
* Copyright SAS WP MEDIA 2020
*/
namespace ImagifyPlugin\Helpers\optimization\status;

Binary file added settings/.DS_Store
Binary file not shown.
37 changes: 37 additions & 0 deletions settings/imagify-skip-gif/imagify-skip-gif.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
/**
* Plugin Name: Imagify | No Auto-Optimization for GIFs
* Description: Excludes GIF files from being auto-optimized once they’re uploaded.
* Plugin URI: https://github.com/wp-media/imagify-helpers/tree/master/optimization/imagify-no-auto-optimize-gif/
* Author: Imagify Support Team
* Author URI: http://imagify.io/
* License: GNU General Public License v2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*
* Copyright SAS WP MEDIA 2018
*/
namespace ImagifyPlugin\Helpers\optimization\auto;

defined( 'ABSPATH' ) or die();

add_filter( 'imagify_auto_optimize_attachment', __NAMESPACE__ . '\no_optimize_gif', 10, 3 );
/**
* Prevent automatic optimization for GIF.
*
* @author Grégory Viguier
* @author Caspar Hübinger
*
* @param bool $optimize True to optimize, false otherwise.
* @param int $attachment_id Attachment ID.
* @param array $metadata An array of attachment meta data.
* @return bool
*/
function no_optimize_gif( $optimize, $attachment_id, $metadata ) {
if ( ! $optimize ) {
return false;
}

$mime_type = get_post_mime_type( $attachment_id );

return 'image/gif' !== $mime_type;
}
Binary file added settings/imagify-skip-gif/imagify-skip-gif.zip
Binary file not shown.
37 changes: 37 additions & 0 deletions settings/imagify-skip-pdf/imagify-skip-pdf.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
/**
* Plugin Name: Imagify | No Auto-Optimization for PDFs
* Description: Excludes PDF files from being auto-optimized once they’re uploaded.
* Plugin URI: https://github.com/wp-media/imagify-helpers/tree/master/optimization/imagify-no-auto-optimize-pdf/
* Author: Imagify Support Team
* Author URI: http://imagify.io/
* License: GNU General Public License v2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*
* Copyright SAS WP MEDIA 2018
*/
namespace ImagifyPlugin\Helpers\optimization\auto;

defined( 'ABSPATH' ) or die();

add_filter( 'imagify_auto_optimize_attachment', __NAMESPACE__ . '\no_optimize_pdf', 10, 3 );
/**
* Prevent automatic optimization for PDF.
*
* @author Grégory Viguier
* @author Caspar Hübinger
*
* @param bool $optimize True to optimize, false otherwise.
* @param int $attachment_id Attachment ID.
* @param array $metadata An array of attachment meta data.
* @return bool
*/
function no_optimize_pdf( $optimize, $attachment_id, $metadata ) {
if ( ! $optimize ) {
return false;
}

$mime_type = get_post_mime_type( $attachment_id );

return 'application/pdf' !== $mime_type;
}
Binary file added settings/imagify-skip-pdf/imagify-skip-pdf.zip
Binary file not shown.
Binary file added settings/imgf-custom-site-root/.DS_Store
Binary file not shown.
35 changes: 35 additions & 0 deletions settings/imgf-custom-site-root/imgf-custom-site-root.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/**
* Plugin Name: Imagify Custom Site Root
* Description: Fix the site path in Imagify.
* Version: 1.0
* Author: WP Media
* Author URI: https://wp-media.me/
* Licence: GPLv2
*
* Copyright 2020 WP Media
*/

defined( 'ABSPATH' ) || die( 'Cheatin\' uh?' );

add_filter( 'imagify_site_root', 'imgf_custom_site_root', 10001 );
/**
* Filter the path to the site's root.
*
* @since 1.0
* @author Grégory Viguier
*
* @param string $root_path Path to the site's root. Default is null.
*/
function imgf_custom_site_root( $root_path ) {
$upload_basedir = imagify_get_filesystem()->get_upload_basedir( true );

if ( strpos( $upload_basedir, '/wp-content/' ) === false ) {
return $root_path;
}

$upload_basedir = explode( '/wp-content/', $upload_basedir );
$upload_basedir = reset( $upload_basedir );

return trailingslashit( $upload_basedir );
}
Binary file not shown.