The gform_postimage_title Gravity Forms filter allows you to modify the “Title” label of the Post Image Title field when creating it.
Usage
add_filter('gform_postimage_title', 'your_function_name', 10, 2);
To target a specific form, append the form ID to the hook name:
add_filter('gform_postimage_title_5', 'your_function_name', 10, 2);
Parameters
- $label (string): The label to be filtered.
- $form_id (integer): The current form’s ID.
More information
See Gravity Forms Docs: gform_postimage_title
Examples
Change the default Post Image Title label
This code changes the default Post Image Title label to “Image Title”:
add_filter('gform_postimage_title', 'change_postimage_title', 10, 2); function change_postimage_title($label, $form_id) { return 'Image Title'; }
Change the Post Image Title label for a specific form
This code changes the Post Image Title label to “Custom Image Title” for form ID 3:
add_filter('gform_postimage_title_3', 'change_postimage_title_for_form_3', 10, 2); function change_postimage_title_for_form_3($label, $form_id) { return 'Custom Image Title'; }
Change the Post Image Title label based on the form ID
This code changes the Post Image Title label depending on the form ID:
add_filter('gform_postimage_title', 'change_postimage_title_based_on_form', 10, 2); function change_postimage_title_based_on_form($label, $form_id) { if ($form_id == 1) { return 'Form 1 Image Title'; } elseif ($form_id == 2) { return 'Form 2 Image Title'; } else { return $label; } }
Add a prefix to the Post Image Title label
This code adds a prefix “My Site – ” to the Post Image Title label:
add_filter('gform_postimage_title', 'add_prefix_to_postimage_title', 10, 2); function add_prefix_to_postimage_title($label, $form_id) { return 'My Site - ' . $label; }
Add a suffix to the Post Image Title label
This code adds a suffix ” (required)” to the Post Image Title label:
add_filter('gform_postimage_title', 'add_suffix_to_postimage_title', 10, 2); function add_suffix_to_postimage_title($label, $form_id) { return $label . ' (required)'; }