Using Gravity Forms ‘gform_ajax_spinner_url’ PHP filter

The gform_ajax_spinner_url Gravity Forms PHP filter allows you to change the default AJAX spinner image.

Usage

add_filter('gform_ajax_spinner_url', 'custom_spinner_image', 10, 2);

To apply this filter per form, add the form ID after the hook name:

add_filter('gform_ajax_spinner_url_6', 'custom_spinner_image', 10, 2);

Parameters

  • $image_src (string): The spinner image URL to be filtered.
  • $form (Form Object): The current form.

More information

See Gravity Forms Docs: gform_ajax_spinner_url

Examples

Change the spinner image to a custom image file

add_filter('gform_ajax_spinner_url', 'spinner_url', 10, 2);

function spinner_url($image_src, $form) {
    // Replace the spinner image URL with your custom image URL
    return "http://www.example.com/spinner.png";
}

Change the spinner image per form

add_filter('gform_ajax_spinner_url_3', 'spinner_url_form3', 10, 2);

function spinner_url_form3($image_src, $form) {
    // Replace the spinner image URL for form 3 with your custom image URL
    return "http://www.example.com/form3_spinner.png";
}

Change the spinner image based on form ID

add_filter('gform_ajax_spinner_url', 'spinner_url_based_on_form', 10, 2);

function spinner_url_based_on_form($image_src, $form) {
    // Check the form ID and set the spinner URL accordingly
    if ($form['id'] == 1) {
        return "http://www.example.com/form1_spinner.png";
    } elseif ($form['id'] == 2) {
        return "http://www.example.com/form2_spinner.png";
    }

    // Return the default spinner URL for other forms
    return $image_src;
}

Use an SVG spinner image

add_filter('gform_ajax_spinner_url', 'use_svg_spinner', 10, 2);

function use_svg_spinner($image_src, $form) {
    // Replace the spinner image URL with your custom SVG image URL
    return "http://www.example.com/spinner.svg";
}

Use a data URI spinner image

add_filter('gform_ajax_spinner_url', 'use_data_uri_spinner', 10, 2);

function use_data_uri_spinner($image_src, $form) {
    // Replace the spinner image URL with a data URI
    return "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPHN2ZyB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiB2aWV3Qm94PSIwIDAgMTAwIDEwMCIgZmlsbD0ibm9uZSI+CiAgPGc+CiAgICA8cGF0aCBkPSJNMTAwIDEwMHYxMDBoMTAwcjEwMHoiIGZpbGw9IiNjY2MiIC8+CiAgPC9nPgogIDxnPgogICAgPHBhdGggZD0iTTI1LjUgNTMuMmwtMi45LTIuOWwtMy42LTMuNmwtMi45LTIuOWwtMy42LTMuNmwtMi45LTIuOWwtMy42LTMuNkw1LjUgMTIuOGwtMS41LTEuNWwtMy42LTMuNmwtMi45LTIuOWwtMy42LTMuNloiIGZpbGw9IiMwMDAiIC8+CiAgPC9nPgogIDxnPgogICAgPHBhdGggZD0iTTM5LjUgMjQuN2wtMi44LTIuOC0zLjYtMy42LTIuOC0yLjgtMy42WiIgZmlsbD0iI2ZmZiIgLz4KICA8L2c+CiA8L3N2Zz4K"
}