summaryrefslogtreecommitdiff
path: root/model/Post.php
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2022-07-11 15:01:02 +0300
committerEvgeny Zinoviev <me@ch1p.io>2022-07-11 15:01:02 +0300
commitc2f382aba86aaebb9806ff1b43c1af69992e9a10 (patch)
treeaee205721fd675926c5e7163eec0dddc448f7813 /model/Post.php
parent24982a48f570b89e537850dda4a4d1ac33ea919f (diff)
support dark mode for images with alpha channel
Diffstat (limited to 'model/Post.php')
-rw-r--r--model/Post.php18
1 files changed, 8 insertions, 10 deletions
diff --git a/model/Post.php b/model/Post.php
index 10a396b..b0360ac 100644
--- a/model/Post.php
+++ b/model/Post.php
@@ -22,8 +22,8 @@ class Post extends Model {
$data['update_ts'] = $cur_ts;
if ($data['md'] != $this->md) {
- $data['html'] = \markup::markdownToHtml($data['md']);
- $data['text'] = \markup::htmlToText($data['html']);
+ $data['html'] = markup::markdownToHtml($data['md']);
+ $data['text'] = markup::htmlToText($data['html']);
}
parent::edit($data);
@@ -31,15 +31,15 @@ class Post extends Model {
}
public function updateHtml() {
- $html = \markup::markdownToHtml($this->md);
+ $html = markup::markdownToHtml($this->md);
$this->html = $html;
getDb()->query("UPDATE posts SET html=? WHERE id=?", $html, $this->id);
}
public function updateText() {
- $html = \markup::markdownToHtml($this->md);
- $text = \markup::htmlToText($html);
+ $html = markup::markdownToHtml($this->md);
+ $text = markup::htmlToText($html);
$this->text = $text;
getDb()->query("UPDATE posts SET text=? WHERE id=?", $text, $this->id);
@@ -81,10 +81,9 @@ class Post extends Model {
return date('j F Y', $this->updateTs);
}
- public function getHtml(bool $retina): string {
+ public function getHtml(bool $is_retina, string $theme): string {
$html = $this->html;
- if ($retina)
- $html = markup::htmlRetinaFix($html);
+ $html = markup::htmlImagesFix($html, $is_retina, $theme);
return $html;
}
@@ -173,9 +172,8 @@ class Post extends Model {
foreach ($images[$u->randomId] as $s) {
list($w, $h) = $s;
list($w, $h) = $u->getImagePreviewSize($w, $h);
- if ($u->createImagePreview($w, $h, $update)) {
+ if ($u->createImagePreview($w, $h, $update, $u->imageMayHaveAlphaChannel()))
$images_affected++;
- }
}
}