Skip to content

Instantly share code, notes, and snippets.

@adam-laita
Created August 15, 2019 14:36
Show Gist options
  • Select an option

  • Save adam-laita/3f2fa9c773122c63e4de71a92e2196c2 to your computer and use it in GitHub Desktop.

Select an option

Save adam-laita/3f2fa9c773122c63e4de71a92e2196c2 to your computer and use it in GitHub Desktop.
WordPress - Auto Cloudinary - Defaults (plugin)
<?php
/*
Plugin Name: Auto Cloudinary - Defaults
Plugin URI: https://gist.github.com/TheALuminium/3f2fa9c773122c63e4de71a92e2196c2
Description: A simple add-on that sets the recommended compression values and format for the Auto Cloudinary plugin.
Version: 1.0
Author: Adam Laita
Author URI: https://www.laita.cz/en
License: GPL2
*/
function laita_auto_cloudinary_defaults() {
// checks if the Auto Cloudinary plugin exists
if ( function_exists( 'cloudinary_url' ) ) {
// adds specific parameters for cloudinary URLs
add_filter( 'cloudinary_default_args', function( $args ) {
$args['transform']['quality'] = 'auto:eco';
$args['transform']['fetch_format'] = 'auto';
return $args;
} );
}
}
add_action( 'plugins_loaded', 'laita_auto_cloudinary_defaults' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment