aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kostikov <max@kostikov.co>2020-03-01 16:23:24 +0100
committerMax Kostikov <max@kostikov.co>2020-03-01 16:23:24 +0100
commit85c07d57fe0f468eb8cc84584f3636b590aa929f (patch)
treeee4bd761efbd1ffd110575a85b4594857f377989
parent06f2979e04db2c5eb7e10bc4967d750209a4cc73 (diff)
parent16fd618380d2f88524b3545f751690b39be084f5 (diff)
downloadvolse-hubzilla-85c07d57fe0f468eb8cc84584f3636b590aa929f.tar.gz
volse-hubzilla-85c07d57fe0f468eb8cc84584f3636b590aa929f.tar.bz2
volse-hubzilla-85c07d57fe0f468eb8cc84584f3636b590aa929f.zip
Merge branch 'dev' into 'dev'
rework img alt text - preserve legacy bbcode See merge request hubzilla/core!1844
-rw-r--r--include/bbcode.php52
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=\&quot\;(.*?)\&quot\;/ism", $attributes, $matches);
+ if ($x) {
+ $alt = $matches[1];
+ }
+
+ $x = preg_match("/width='(.*?)'/ism", $attributes, $matches);
+ if ($x) {
+ $width = $matches[1];
+ }
+
+ $x = preg_match("/width=\&quot\;(.*?)\&quot\;/ism", $attributes, $matches);
+ if ($x) {
+ $width = $matches[1];
+ }
+
+ $x = preg_match("/height='(.*?)'/ism", $attributes, $matches);
+ if ($x) {
+ $height = $matches[1];
+ }
+
+ $x = preg_match("/height=\&quot\;(.*?)\&quot\;/ism", $attributes, $matches);
+ if ($x) {
+ $height = $matches[1];
+ }
+
+ $x = preg_match("/style='(.*?)'/ism", $attributes, $matches);
+ if ($x) {
+ $style = $matches[1];
+ }
+
+ $x = preg_match("/style=\&quot\;(.*?)\&quot\;/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);
}