How to theme search button as image [Drupal]

Hook to the search form alter function to turn the search button into an image. Uses drupal_get_path to add theme-relative URL for button image.

/**
* Implements hook_form_alter().
*
* @see https://gist.github.com/751854
*/
function MYTHEME_form_search_block_form_alter(&$form, &$form_state) {
	$form['actions']['submit']['#type'] = 'image_button';
	$form['actions']['submit']['#src'] = drupal_get_path('theme', 'MYTHEME') . '/images/button-search.png';
} 

From Make Drupal 7 search button an image button.

Leave a Reply

Your email address will not be published. Required fields are marked *