mirror of
https://github.com/friendica/friendica
synced 2025-04-26 05:10:11 +00:00
Issue 14491: CSS class for pictures with or without alt descriptions
This commit is contained in:
parent
2d7964ad7c
commit
e9064aff32
3 changed files with 11 additions and 10 deletions
|
@ -686,7 +686,7 @@ class BBCode
|
||||||
// to the last element
|
// to the last element
|
||||||
$newbody = str_replace(
|
$newbody = str_replace(
|
||||||
'[$#saved_image' . $cnt . '#$]',
|
'[$#saved_image' . $cnt . '#$]',
|
||||||
'<img src="' . self::proxyUrl($image, self::INTERNAL, $uriid) . '" alt="' . DI::l10n()->t('Image/photo') . '" class="empty-description"/>',
|
'<img src="' . self::proxyUrl($image, self::INTERNAL, $uriid) . '" alt="" class="empty-description"/>',
|
||||||
$newbody
|
$newbody
|
||||||
);
|
);
|
||||||
$cnt++;
|
$cnt++;
|
||||||
|
@ -849,6 +849,7 @@ class BBCode
|
||||||
$img_str .= ' ' . $key . '="' . htmlspecialchars($value, ENT_COMPAT) . '"';
|
$img_str .= ' ' . $key . '="' . htmlspecialchars($value, ENT_COMPAT) . '"';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$img_str .= ' ' . empty($attributes['alt']) ? 'class="empty-description"' : 'class="has-alt-description"';
|
||||||
return $img_str . '>';
|
return $img_str . '>';
|
||||||
},
|
},
|
||||||
$text
|
$text
|
||||||
|
@ -1826,8 +1827,8 @@ class BBCode
|
||||||
$text
|
$text
|
||||||
);
|
);
|
||||||
|
|
||||||
$text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '<img src="$3" style="width: $1px;" >', $text);
|
$text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '<img src="$3" style="width: $1px;" alt="" class="empty-description">', $text);
|
||||||
$text = preg_replace("/\[zmg\=([0-9]*)x([0-9]*)\](.*?)\[\/zmg\]/ism", '<img class="zrl" src="$3" style="width: $1px;" >', $text);
|
$text = preg_replace("/\[zmg\=([0-9]*)x([0-9]*)\](.*?)\[\/zmg\]/ism", '<img class="zrl" src="$3" style="width: $1px;" alt="" class="empty-description">', $text);
|
||||||
|
|
||||||
$text = preg_replace_callback(
|
$text = preg_replace_callback(
|
||||||
"/\[[iz]mg\=(.*?)\](.*?)\[\/[iz]mg\]/ism",
|
"/\[[iz]mg\=(.*?)\](.*?)\[\/[iz]mg\]/ism",
|
||||||
|
@ -1836,7 +1837,7 @@ class BBCode
|
||||||
$alt = htmlspecialchars($matches[2], ENT_COMPAT);
|
$alt = htmlspecialchars($matches[2], ENT_COMPAT);
|
||||||
// Fix for Markdown problems with Diaspora, see issue #12701
|
// Fix for Markdown problems with Diaspora, see issue #12701
|
||||||
if (($simple_html != self::DIASPORA) || strpos($matches[2], '"') === false) {
|
if (($simple_html != self::DIASPORA) || strpos($matches[2], '"') === false) {
|
||||||
return '<img src="' . $matches[1] . '" alt="' . $alt . '" title="' . $alt . '">';
|
return '<img src="' . $matches[1] . '" alt="' . $alt . '" title="' . $alt . '" class="' . (empty($alt) ? 'empty-description' : 'has-alt-description') . '">';
|
||||||
} else {
|
} else {
|
||||||
return '<img src="' . $matches[1] . '" alt="' . $alt . '">';
|
return '<img src="' . $matches[1] . '" alt="' . $alt . '">';
|
||||||
}
|
}
|
||||||
|
@ -1859,8 +1860,8 @@ class BBCode
|
||||||
$text
|
$text
|
||||||
);
|
);
|
||||||
|
|
||||||
$text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '<img src="$1" alt="' . DI::l10n()->t('Image/photo') . '" class="empty-description"/>', $text);
|
$text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '<img src="$1" alt="" class="empty-description"/>', $text);
|
||||||
$text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '<img src="$1" alt="' . DI::l10n()->t('Image/photo') . '" class="empty-description" />', $text);
|
$text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '<img src="$1" alt="" class="empty-description" />', $text);
|
||||||
|
|
||||||
$text = self::convertImages($text, $simple_html, $uriid);
|
$text = self::convertImages($text, $simple_html, $uriid);
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
*}}
|
*}}
|
||||||
{{if $image->preview}}
|
{{if $image->preview}}
|
||||||
<a data-fancybox="{{$image->uriId}}" href="{{$image->url}}"><img src="{{$image->preview}}" alt="{{$image->description}}" title="{{$image->description}}" loading="lazy"></a>
|
<a data-fancybox="{{$image->uriId}}" href="{{$image->url}}"><img src="{{$image->preview}}" alt="{{$image->description}}" title="{{$image->description}}" {{if $image->description}}class="has-alt-description"{{else}}class="empty-description"{{/if}} loading="lazy"></a>
|
||||||
{{else}}
|
{{else}}
|
||||||
<figure>
|
<figure>
|
||||||
<img src="{{$image->url}}" alt="{{$image->description}}" title="{{$image->description}}" loading="lazy">
|
<img src="{{$image->url}}" alt="{{$image->description}}" title="{{$image->description}}" {{if $image->description}}class="has-alt-description"{{else}}class="empty-description"{{/if}} loading="lazy">
|
||||||
{{if $image->description}}
|
{{if $image->description}}
|
||||||
<figcaption>{{$image->description}}</figcaption>
|
<figcaption>{{$image->description}}</figcaption>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
@ -14,10 +14,10 @@
|
||||||
<figure class="img-allocated-height" style="width: {{$allocated_width|default:"auto"}}; padding-bottom: {{$allocated_height}}">
|
<figure class="img-allocated-height" style="width: {{$allocated_width|default:"auto"}}; padding-bottom: {{$allocated_height}}">
|
||||||
{{if $image->preview}}
|
{{if $image->preview}}
|
||||||
<a data-fancybox="uri-id-{{$image->uriId}}" href="{{$image->url}}">
|
<a data-fancybox="uri-id-{{$image->uriId}}" href="{{$image->url}}">
|
||||||
<img src="{{$image->preview}}" alt="{{$image->description}}" title="{{$image->description}}" loading="lazy">
|
<img src="{{$image->preview}}" alt="{{$image->description}}" title="{{$image->description}}" {{if $image->description}}class="has-alt-description"{{else}}class="empty-description"{{/if}} loading="lazy">
|
||||||
</a>
|
</a>
|
||||||
{{else}}
|
{{else}}
|
||||||
<img src="{{$image->url}}" alt="{{$image->description}}" title="{{$image->description}}" loading="lazy">
|
<img src="{{$image->url}}" alt="{{$image->description}}" title="{{$image->description}}" {{if $image->description}}class="has-alt-description"{{else}}class="empty-description"{{/if}} loading="lazy">
|
||||||
{{if $image->description}}
|
{{if $image->description}}
|
||||||
<figcaption>{{$image->description}}</figcaption>
|
<figcaption>{{$image->description}}</figcaption>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue