Skip to content

Instantly share code, notes, and snippets.

@plugin-republic
Last active July 1, 2021 19:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plugin-republic/9f19211573b9046b596d0eaaca85a48f to your computer and use it in GitHub Desktop.
Save plugin-republic/9f19211573b9046b596d0eaaca85a48f to your computer and use it in GitHub Desktop.
<?php
/**
* Filter the aspect ratio by field idea
* @param $ratio Default ratio
* @param $id The field ID in the form, pewc_group_1234_5678
* @param $field The field object
*/
function prefix_aspect_ratio( $ratio, $id, $field ) {
// Check for our field ID here
// Change 8888 to the ID of the field where you want to specify a different ratio
if( $field['field_id'] == 8888 ) {
$ratio = '16/9';
} else if( $field['field_id'] == 9999 ) {
$ratio = '2/3';
}
return $ratio;
}
add_filter( 'wcpauau_aspect_ratio', 'prefix_aspect_ratio', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment