diff options
author | zotlabs <mike@macgirvin.com> | 2020-02-29 13:08:16 -0800 |
---|---|---|
committer | zotlabs <mike@macgirvin.com> | 2020-02-29 13:08:16 -0800 |
commit | 16fd618380d2f88524b3545f751690b39be084f5 (patch) | |
tree | 43f65a7901fea8e502fffdec21aaa094ffd528ce /include | |
parent | a776f69a59718b3e9034ef12f543b0aaef317855 (diff) | |
download | volse-hubzilla-16fd618380d2f88524b3545f751690b39be084f5.tar.gz volse-hubzilla-16fd618380d2f88524b3545f751690b39be084f5.tar.bz2 volse-hubzilla-16fd618380d2f88524b3545f751690b39be084f5.zip |
rework img alt text - preserve legacy bbcode
Diffstat (limited to 'include')
-rw-r--r-- | include/bbcode.php | 52 |
1 files changed, 49 insertions, 3 deletions
diff --git a/include/bbcode.php b/include/bbcode.php index bb7b9e2dd..b2e3f1d3b 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -668,15 +668,60 @@ function bb_imgoptions($match) { $alt = false; $style = EMPTY_STR; + + $attributes = $match[3]; + + $x = preg_match("/alt='(.*?)'/ism", $attributes, $matches); + if ($x) { + $alt = $matches[1]; + } + + $x = preg_match("/alt=\"\;(.*?)\"\;/ism", $attributes, $matches); + if ($x) { + $alt = $matches[1]; + } + + $x = preg_match("/width='(.*?)'/ism", $attributes, $matches); + if ($x) { + $width = $matches[1]; + } + + $x = preg_match("/width=\"\;(.*?)\"\;/ism", $attributes, $matches); + if ($x) { + $width = $matches[1]; + } + + $x = preg_match("/height='(.*?)'/ism", $attributes, $matches); + if ($x) { + $height = $matches[1]; + } + + $x = preg_match("/height=\"\;(.*?)\"\;/ism", $attributes, $matches); + if ($x) { + $height = $matches[1]; + } + + $x = preg_match("/style='(.*?)'/ism", $attributes, $matches); + if ($x) { + $style = $matches[1]; + } + + $x = preg_match("/style=\"\;(.*?)\"\;/ism", $attributes, $matches); + if ($x) { + $style = $matches[1]; + } + + // legacy img options if ($match[2] === '=') { - // pull out (optional) size declarations first + // pull out (optional) legacy size declarations first if (preg_match("/([0-9]*)x([0-9]*)/ism",$match[3],$local_match)) { $width = intval($local_match[1]); } $match[3] = substr($match[3],strpos($match[3],' ')); } - // then (optional) float specifiers + + // then (optional) legacy float specifiers if ($n = strpos($match[3],'float=left') !== false) { $float = 'left'; $match[3] = substr($match[3],$n + 10); @@ -685,8 +730,9 @@ function bb_imgoptions($match) { $float = 'right'; $match[3] = substr($match[3],$n + 11); } + // finally alt text which extends to the close of the tag - if ($n = strpos($match[3],'alt=') !== false) { + if ((! $alt) && ($n = strpos($match[3],'alt=') !== false)) { $alt = substr($match[3],$n + 4); } |