1. Home
  2. Knowledge Base
  3. Add-Ons Ultimate: Advanced Uploads
  4. Aspect Ratio
  5. Filtering the aspect ratio by field ID
  1. Home
  2. Knowledge Base
  3. Add-Ons Ultimate: Advanced Uploads
  4. Filtering the aspect ratio by field ID

Filtering the aspect ratio by field ID

By default, the aspect ratio is set globally in the plugin settings. However, you might want to have different aspect ratios for different products and fields.

To do so, you can use this snippet:

<?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 );

Here’s how to add a snippet.

Was this article helpful?

Need More Support?

If you can't find the answer that you're looking for, then please use the link below to raise a support ticket.
Contact Support