function _hide_submit_get_image in Hide submit button 7
Same name and namespace in other branches
- 5 hide_submit.module \_hide_submit_get_image()
- 6 hide_submit.module \_hide_submit_get_image()
get the image according to user selection, default, random etc...
2 calls to _hide_submit_get_image()
- _hide_submit_get_javascript_settings in ./
hide_submit.module - Get javascript code for injection
- _hide_submit_get_message in ./
hide_submit.module - Get javascript code for injection
File
- ./
hide_submit.module, line 284 - Hide the submit button after clicked to prevent/reduce duplicate postings.
Code
function _hide_submit_get_image() {
// Use static to assure the same image is returned for the current page
static $image = FALSE;
if ($image !== FALSE) {
return $image;
}
if (variable_get('hide_submit_text_only', FALSE)) {
$image = FALSE;
}
else {
$image = variable_get('hide_submit_image', HIDE_SUBMIT_DEFAULT_IMAGE);
if (is_array($image)) {
list($usec, $sec) = explode(' ', microtime());
srand((double) $sec + (double) $usec * 100000);
$image = $image[rand() % count($image)];
}
}
// Allow modules to modify the image.
drupal_alter('hide_submit_image', $image);
// Theme should be able to play with those settings too.
// Theme may not be initialized at this time, so we have to force its
// initialization if $GLOBALS['theme'] is NULL.
// Because of this initialisation, the module weight is heavy, to let
// others modules (like theme_keys or section) do their job before.
if (empty($GLOBALS['theme'])) {
init_theme();
}
$function = $GLOBALS['theme'] . '_hide_submit_image_alter';
if (function_exists($function)) {
$function($image);
}
return $image;
}