Created
October 23, 2022 23:11
-
-
Save jetsloth/17fc37cdb9719fd8fbfc01a675ad6fbe to your computer and use it in GitHub Desktop.
Customise the image size used for Image Choices
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'gform_pre_render', 'custom_image_choices_size' ); | |
add_filter( 'gform_pre_validation', 'custom_image_choices_size' ); | |
add_filter( 'gform_pre_submission_filter', 'custom_image_choices_size' ); | |
add_filter( 'gform_admin_pre_render', 'custom_image_choices_size' ); | |
function custom_image_choices_size( $form ) { | |
foreach ( $form["fields"] as &$field ) { | |
if ( property_exists($field, "imageChoices_enableImages") && !empty($field->imageChoices_enableImages) ) { | |
foreach( $field["choices"] as $i => $choice ) { | |
$id = $choice["imageChoices_imageID"]; | |
$field["choices"][$i]["imageChoices_image"] = wp_get_attachment_image_src($id, 'full');// replace "medium" with whichever size you need | |
} | |
} | |
} | |
return $form; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment