summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2021-02-04 18:49:53 +0100
committerAndrey Andreev <narf@devilix.net>2021-02-04 18:49:53 +0100
commit324628c27ca82e89d5e3a85034127835d29dd9fc (patch)
treed0689a8d42684123c058c57d08632c53030b1e4b
parentfda124cfd788a9a70cd8608648513271fb859cd9 (diff)
[ci skip] Add 'img_class' option to CAPTCHA helper
Close #5999
-rw-r--r--system/helpers/captcha_helper.php6
-rw-r--r--user_guide_src/source/changelog.rst1
2 files changed, 6 insertions, 1 deletions
diff --git a/system/helpers/captcha_helper.php b/system/helpers/captcha_helper.php
index f178903b2..6fce05267 100644
--- a/system/helpers/captcha_helper.php
+++ b/system/helpers/captcha_helper.php
@@ -69,6 +69,7 @@ if ( ! function_exists('create_captcha'))
'img_width' => '150',
'img_height' => '30',
'img_alt' => 'captcha',
+ 'img_class' => '',
'font_path' => '',
'font_size' => 16,
'expiration' => 7200,
@@ -372,7 +373,10 @@ if ( ! function_exists('create_captcha'))
$img_src = 'data:image/png;base64,'.base64_encode($img_src);
}
- $img = '<img '.($img_id === '' ? '' : 'id="'.$img_id.'"').' src="'.$img_src.'" style="width: '.$img_width.'px; height: '.$img_height .'px; border: 0;" alt="'.$img_alt.'" />';
+ $img_class = trim($img_class);
+ $img_class = (bool) strlen($img_class) ? 'class="'.$img_class.'" ' : '';
+
+ $img = '<img '.($img_id === '' ? '' : 'id="'.$img_id.'"').' src="'.$img_src.'" style="width: '.$img_width.'px; height: '.$img_height .'px; border: 0;" '.$img_class.'alt="'.$img_alt.'" />';
ImageDestroy($im);
return array('word' => $word, 'time' => $now, 'image' => $img, 'filename' => $img_filename);
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index afc309436..4e1734694 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -127,6 +127,7 @@ Release Date: Not Released
- :doc:`CAPTCHA Helper <helpers/captcha_helper>` changes include:
- Added 'img_alt' option with a default value of 'captcha'.
+ - Added 'img_class' option.
- Added ability to generate ``data:image/png;base64`` URIs instead of writing image files to disk.
- Updated to always create PNG images instead of JPEG.