wip for flavor images

This commit is contained in:
Andrew Dolgov 2021-03-08 18:26:13 +03:00
parent cfb4882591
commit 76f5443080
9 changed files with 84 additions and 15 deletions

View File

@ -292,9 +292,12 @@ class Article extends Handler_Protected {
static function _format_enclosures($id,
$always_display_enclosures,
$article_content,
$hide_images = false) {
$hide_images = false,
$enclosures = false) {
if ($enclosures === false)
$enclosures = self::_get_enclosures($id);
$enclosures = self::_get_enclosures($id);
$enclosures_formatted = "";
/*foreach ($enclosures as &$enc) {

View File

@ -244,6 +244,38 @@ class Feeds extends Handler_Protected {
},
$line);
$this->_mark_timestamp(" pre-enclosures");
if ($line["num_enclosures"] > 0) {
$enclosures = Article::_get_enclosures($id);
$line["enclosures"] = Article::_format_enclosures($id,
$line["always_display_enclosures"],
$line["content"],
$line["hide_images"],
$enclosures);
} else {
$enclosures = [];
$line["enclosures"] = [ 'formatted' => '', 'entries' => [] ];
}
$this->_mark_timestamp(" enclosures");
list ($flavor_image, $flavor_stream, $flavor_kind) = Article::_get_image($enclosures,
$line["content"], // unsanitized
$line["site_url"],
$line);
$line["flavor_image"] = $flavor_image;
$line["flavor_stream"] = $flavor_stream;
/* optional */
if ($flavor_kind)
$line["flavor_kind"] = $flavor_kind;
$this->_mark_timestamp(" flavor image");
$this->_mark_timestamp(" pre-sanitize");
$line["content"] = Sanitizer::sanitize($line["content"],
@ -261,19 +293,6 @@ class Feeds extends Handler_Protected {
}
}
$this->_mark_timestamp(" pre-enclosures");
if ($line["num_enclosures"] > 0) {
$line["enclosures"] = Article::_format_enclosures($id,
$line["always_display_enclosures"],
$line["content"],
$line["hide_images"]);
} else {
$line["enclosures"] = [ 'formatted' => '', 'entries' => [] ];
}
$this->_mark_timestamp(" enclosures");
$line["updated_long"] = TimeHelper::make_local_datetime($line["updated"],true);
$line["updated"] = TimeHelper::make_local_datetime($line["updated"], false, false, false, true);
@ -315,6 +334,7 @@ class Feeds extends Handler_Protected {
}
$this->_mark_timestamp(" color");
$this->_mark_timestamp(" pre-hook_render_cdm");
PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_RENDER_ARTICLE_CDM,

View File

@ -477,6 +477,9 @@ const Headlines = {
<i class="pub-pic pub-${hl.id} material-icons" onclick="Headlines.togglePub(${hl.id})">rss_feed</i>
</div>
<img class="flavor-image" style='background-image: url("${App.escapeHtml(hl.flavor_image)}")'
loading="lazy" src="data:image/gif;base64,R0lGODlhAQABAPAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="/>
<span onclick="return Headlines.click(event, ${hl.id});" data-article-id="${hl.id}" class="titleWrap hlMenuAttach">
${App.getInitParam("debug_headline_ids") ? `<span class="text-muted small">A: ${hl.id} F: ${hl.feed_id}</span>` : ""}
<a class="title" title="${App.escapeHtml(hl.title)}" target="_blank" rel="noopener noreferrer" href="${App.escapeHtml(hl.link)}">

View File

@ -1161,6 +1161,13 @@ video::-webkit-media-controls-overlay-play-button {
.cdm i.material-icons {
color: #777;
}
.cdm img.flavor-image {
width: 32px;
height: 32px;
margin: 8px ! important;
border-radius: 50%;
background-size: cover;
}
.cdm .header {
position: sticky;
top: 0;

View File

@ -1161,6 +1161,13 @@ video::-webkit-media-controls-overlay-play-button {
.cdm i.material-icons {
color: #777;
}
.cdm img.flavor-image {
width: 32px;
height: 32px;
margin: 8px ! important;
border-radius: 50%;
background-size: cover;
}
.cdm .header {
position: sticky;
top: 0;

View File

@ -1161,6 +1161,13 @@ video::-webkit-media-controls-overlay-play-button {
.cdm i.material-icons {
color: #777;
}
.cdm img.flavor-image {
width: 32px;
height: 32px;
margin: 8px ! important;
border-radius: 50%;
background-size: cover;
}
.cdm .header {
position: sticky;
top: 0;

View File

@ -3,6 +3,14 @@
color : @color-icon;
}
img.flavor-image {
width : 32px;
height : 32px;
margin : 8px ! important;
border-radius : 50%;
background-size : cover;
}
.header {
position: sticky;
top : 0;

View File

@ -1162,6 +1162,13 @@ video::-webkit-media-controls-overlay-play-button {
.cdm i.material-icons {
color: #777;
}
.cdm img.flavor-image {
width: 32px;
height: 32px;
margin: 8px ! important;
border-radius: 50%;
background-size: cover;
}
.cdm .header {
position: sticky;
top: 0;

View File

@ -1162,6 +1162,13 @@ video::-webkit-media-controls-overlay-play-button {
.cdm i.material-icons {
color: #777;
}
.cdm img.flavor-image {
width: 32px;
height: 32px;
margin: 8px ! important;
border-radius: 50%;
background-size: cover;
}
.cdm .header {
position: sticky;
top: 0;