Hi Alex,
To make things a bit easier on you moving forward, you can use the filter that we have included in the plugin to alter the form description however you see fit.
The following is a snippet that I have written (and tested), that will append an image before your form description, for all of the forms on your site.
You’ll want to add the following function to the bottom of your functions.php file, ideally you’re using a child theme – so you’ll want to add it there.
If you are not using a child theme, on each update this snippet will be erased and you’ll have to re-add it.
If you are not using a child theme, or just are not comfortable editing functions.php file, you can use an additional third party plugin to add the code to your theme.
The following plugin is one that we recommend frequently to our users:
My Custom Functions
Now for the code:
/**
* Append a custom image to the description for all forms
* @param string $description The form description that is set.
* @param int $form_id The form ID.
* @return string The new form description to use.
*/
function custom_yikes_mailchimp_image( $description, $form_id ) {
$image = wp_get_attachment_image( 7, 'full', false, array(
'class' => 'mailchimp-form-image',
) );
return $image . '<br />' . $description;
}
add_filter( 'yikes-mailchimp-form-description', 'custom_yikes_mailchimp_image', 10, 2 );
You will notice that we have a function wp_get_attachment_image()
which is retrieving an image that you have uploaded to your media library. The number is the ID of the media in your library.
You can easily get the ID of your attachment by going to ‘Media > Library‘ and clicking on the media one time. When the pop up appears, you may notice that the URL also changes (?item=#). The new query string appended to the URL is the ID of the attachment you clicked.
See the following example for an illustration of what I am referring to:
Attachment ID Example
Once you have your attachment ID you can swap it out for the number that we have included in the function. When you swap out the attachment ID, you can save the function and check your form again. You should now see the image appearing before your form.
Let us know if that helps out at all. If you need some additional help, please post here and I will do my best to walk you through anything you may be stuck on.
Thanks!
Evan