I am using the Contact Form 7 plugin on a web site, which has a contact form in the footer of every page and also a contact form in the main area of a dedicated Contact page.
I know how to customise the ajax loader gif in CF7…
function my_wpcf7_ajax_loader () {
return get_stylesheet_directory_uri() . '/images/my-loader-image.gif';
}
add_filter('wpcf7_ajax_loader', 'my_wpcf7_ajax_loader');
…but my problem is that I need to specify two different loader images – one for the footer form and one for the Contact page form. (The reason for this is because one form is on a white background and the other is on a red background, and despite experimenting with different loader gifs I don’t think it is possible to have a loader gif that looks good on both.)
Here’s the solution: https://gist.github.com/tctc91/8271205
As loading image is an
img
element withsrc
attribute, css methods will not be helpful.It would be required to change
src
attribute ofimg
tag through JavaScript and without modifying the core js of contact 7 form plugin (to allow plugin upgrades in future), I have come with following JavaScript solution to apply this change by bruteforce method.Though it may not be the best way, See if it helps.
I read an article with a solid solution for your problem. They gave this solution:
link to the article here:
Note: We’re using a heavily modified twenty twenty theme and NONE of these solutions worked. Tried them all. Updated to latest version of plugin, still the same issue. Can’t disabled plugins one at a time and test by practical means because there are dozens and because we need the ones that we have.