Issue 14174 and 14421: Option to hide emojis and pictures without description

pull/14474/head
Michael 2024-10-18 19:00:13 +00:00
rodzic 159e6e79dc
commit 301717802d
7 zmienionych plików z 245 dodań i 206 usunięć

Wyświetl plik

@ -273,6 +273,13 @@ class Page implements ArrayAccess
'$max_imagesize' => round(Images::getMaxUploadBytes() / 1000000, 0),
]) . $this->page['htmlhead'];
if ($pConfig->get($localUID, 'accessibility', 'hide_empty_descriptions')) {
$this->page['htmlhead'] .= "<style>.empty-description {display: none;}</style>\n";
}
if ($pConfig->get($localUID, 'accessibility', 'hide_custom_emojis')) {
$this->page['htmlhead'] .= "<style>span.emoji.mastodon img {display: none;}</style>\n";
}
}
/**

Wyświetl plik

@ -686,7 +686,7 @@ class BBCode
// to the last element
$newbody = str_replace(
'[$#saved_image' . $cnt . '#$]',
'<img src="' . self::proxyUrl($image, self::INTERNAL, $uriid) . '" alt="' . DI::l10n()->t('Image/photo') . '" />',
'<img src="' . self::proxyUrl($image, self::INTERNAL, $uriid) . '" alt="' . DI::l10n()->t('Image/photo') . '" class="empty-description"/>',
$newbody
);
$cnt++;
@ -1859,8 +1859,8 @@ class BBCode
$text
);
$text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '<img src="$1" alt="' . DI::l10n()->t('Image/photo') . '" />', $text);
$text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '<img src="$1" alt="' . DI::l10n()->t('Image/photo') . '" />', $text);
$text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '<img src="$1" alt="' . DI::l10n()->t('Image/photo') . '" class="empty-description"/>', $text);
$text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '<img src="$1" alt="' . DI::l10n()->t('Image/photo') . '" class="empty-description" />', $text);
$text = self::convertImages($text, $simple_html, $uriid);

Wyświetl plik

@ -3733,6 +3733,9 @@ class Item
continue;
}
if (empty($PostMedia->description) && DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'accessibility', 'hide_empty_descriptions')) {
continue;
}
$images[] = $PostMedia->withUrl(new Uri($src_url))->withPreview(new Uri($preview_url), $preview_size);
}
}

Wyświetl plik

@ -80,23 +80,25 @@ class Display extends BaseSettings
$user = User::getById($uid);
$theme = trim($request['theme']);
$mobile_theme = trim($request['mobile_theme'] ?? '');
$enable_smile = (bool)$request['enable_smile'];
$enable = (array)$request['enable'];
$bookmark = (array)$request['bookmark'];
$channel_languages = (array)$request['channel_languages'];
$first_day_of_week = (bool)$request['first_day_of_week'];
$calendar_default_view = trim($request['calendar_default_view']);
$infinite_scroll = (bool)$request['infinite_scroll'];
$enable_smart_threading = (bool)$request['enable_smart_threading'];
$enable_dislike = (bool)$request['enable_dislike'];
$display_resharer = (bool)$request['display_resharer'];
$stay_local = (bool)$request['stay_local'];
$show_page_drop = (bool)$request['show_page_drop'];
$display_eventlist = (bool)$request['display_eventlist'];
$preview_mode = (int)$request['preview_mode'];
$browser_update = (int)$request['browser_update'];
$theme = trim($request['theme']);
$mobile_theme = trim($request['mobile_theme'] ?? '');
$enable_smile = (bool)$request['enable_smile'];
$enable = (array)$request['enable'];
$bookmark = (array)$request['bookmark'];
$channel_languages = (array)$request['channel_languages'];
$first_day_of_week = (bool)$request['first_day_of_week'];
$calendar_default_view = trim($request['calendar_default_view']);
$infinite_scroll = (bool)$request['infinite_scroll'];
$enable_smart_threading = (bool)$request['enable_smart_threading'];
$enable_dislike = (bool)$request['enable_dislike'];
$display_resharer = (bool)$request['display_resharer'];
$stay_local = (bool)$request['stay_local'];
$hide_empty_descriptions = (bool)$request['hide_empty_descriptions'];
$hide_custom_emojis = (bool)$request['hide_custom_emojis'];
$show_page_drop = (bool)$request['show_page_drop'];
$display_eventlist = (bool)$request['display_eventlist'];
$preview_mode = (int)$request['preview_mode'];
$browser_update = (int)$request['browser_update'];
if ($browser_update != -1) {
$browser_update = $browser_update * 1000;
if ($browser_update < 10000) {
@ -147,10 +149,13 @@ class Display extends BaseSettings
$this->pConfig->set($uid, 'system', 'show_page_drop' , $show_page_drop);
$this->pConfig->set($uid, 'system', 'display_eventlist' , $display_eventlist);
$this->pConfig->set($uid, 'system', 'preview_mode' , $preview_mode);
$this->pConfig->set($uid, 'system', 'network_timelines' , $network_timelines);
$this->pConfig->set($uid, 'system', 'enabled_timelines' , $enabled_timelines);
$this->pConfig->set($uid, 'channel', 'languages' , $channel_languages);
$this->pConfig->set($uid, 'accessibility', 'hide_empty_descriptions', $hide_empty_descriptions);
$this->pConfig->set($uid, 'accessibility', 'hide_custom_emojis' , $hide_custom_emojis);
$this->pConfig->set($uid, 'calendar', 'first_day_of_week' , $first_day_of_week);
$this->pConfig->set($uid, 'calendar', 'default_view' , $calendar_default_view);
@ -240,6 +245,9 @@ class Display extends BaseSettings
$stay_local = $this->pConfig->get($uid, 'system', 'stay_local', false);
$show_page_drop = $this->pConfig->get($uid, 'system', 'show_page_drop', true);
$display_eventlist = $this->pConfig->get($uid, 'system', 'display_eventlist', true);
$hide_empty_descriptions = $this->pConfig->get($uid, 'accessibility', 'hide_empty_descriptions', false);
$hide_custom_emojis = $this->pConfig->get($uid, 'accessibility', 'hide_custom_emojis', false);
$preview_mode = $this->pConfig->get($uid, 'system', 'preview_mode', BBCode::PREVIEW_LARGE);
$preview_modes = [
@ -320,6 +328,8 @@ class Display extends BaseSettings
'$show_page_drop' => ['show_page_drop' , $this->t('Show the post deletion checkbox'), $show_page_drop, $this->t("Display the checkbox for the post deletion on the network page.")],
'$display_eventlist' => ['display_eventlist' , $this->t('DIsplay the event list'), $display_eventlist, $this->t("Display the birthday reminder and event list on the network page.")],
'$preview_mode' => ['preview_mode' , $this->t('Link preview mode'), $preview_mode, $this->t('Appearance of the link preview that is added to each post with a link.'), $preview_modes, false],
'$hide_empty_descriptions' => ['hide_empty_descriptions' , $this->t('Hide pictures with empty alternative text'), $hide_empty_descriptions, $this->t("Don't display pictures that are missing the alternative text.")],
'$hide_custom_emojis' => ['hide_custom_emojis' , $this->t('Hide custom emojis'), $hide_custom_emojis, $this->t("Don't display custom emojis.")],
'$timeline_label' => $this->t('Label'),
'$timeline_descriptiom' => $this->t('Description'),

Plik diff jest za duży Load Diff

Wyświetl plik

@ -28,7 +28,8 @@
{{include file="field_checkbox.tpl" field=$show_page_drop}}
{{include file="field_checkbox.tpl" field=$display_eventlist}}
{{include file="field_select.tpl" field=$preview_mode}}
{{include file="field_checkbox.tpl" field=$hide_empty_descriptions}}
{{include file="field_checkbox.tpl" field=$hide_custom_emojis}}
<h2>{{$timeline_title}}</h2>
{{$timeline_explanation}}
<table class="table table-condensed table-striped table-bordered">

Wyświetl plik

@ -75,6 +75,8 @@
{{include file="field_checkbox.tpl" field=$show_page_drop}}
{{include file="field_checkbox.tpl" field=$display_eventlist}}
{{include file="field_select.tpl" field=$preview_mode}}
{{include file="field_checkbox.tpl" field=$hide_empty_descriptions}}
{{include file="field_checkbox.tpl" field=$hide_custom_emojis}}
</div>
<div class="panel-footer">
<button type="submit" name="submit" class="btn btn-primary" value="{{$submit}}">{{$submit}}</button>