diff --git a/bl-kernel/admin/views/settings.php b/bl-kernel/admin/views/settings.php
index 601305a8..5159cfdb 100644
--- a/bl-kernel/admin/views/settings.php
+++ b/bl-kernel/admin/views/settings.php
@@ -455,6 +455,15 @@ echo Bootstrap::formInputHidden(array(
'tip' => ''
));
+ echo Bootstrap::formSelectGallery(array(
+ 'name' => 'defaultThumbnail',
+ 'label' => $L->g('Default Thumbnail'),
+ 'selected' => $site->defaultThumbnail(),
+ 'class' => '',
+ 'placeholder' => '',
+ 'tip' => ''
+ ));
+
echo Bootstrap::cardEnd();
echo Bootstrap::cardBegin($L->g('Thumbnails'));
diff --git a/bl-kernel/helpers/media.class.php b/bl-kernel/helpers/media.class.php
index 976aa02f..5e932a36 100644
--- a/bl-kernel/helpers/media.class.php
+++ b/bl-kernel/helpers/media.class.php
@@ -23,4 +23,19 @@ class MediaHelper {
return MediaHelper::getImage($site->favicon());
}
+ public static function getDefaultThumbnail()
+ {
+ global $site;
+ return MediaHelper::getImage($site->defaultThumbnail());
+ }
+
+ public static function toHTML($media, $classes = "")
+ {
+ if ($media != null) {
+ return $media->toHTML($classes);
+ } else {
+ return "";
+ }
+ }
+
}
\ No newline at end of file
diff --git a/bl-kernel/site.class.php b/bl-kernel/site.class.php
index cf531db4..a48cf730 100644
--- a/bl-kernel/site.class.php
+++ b/bl-kernel/site.class.php
@@ -59,6 +59,7 @@ class Site extends dbJSON
'avatarQuality' => 100,
'logo' => '',
'favicon' => '',
+ 'defaultThumbnail' => '',
'markdownParser' => true,
'customFields' => '{}',
'socials' => array()
@@ -354,6 +355,11 @@ class Site extends dbJSON
return $this->getField('favicon');
}
+ public function defaultThumbnail()
+ {
+ return $this->getField('defaultThumbnail');
+ }
+
// Returns the full domain and base url
// For example, https://www.domain.com/koblog
public function url()
diff --git a/bl-plugins/opengraph/plugin.php b/bl-plugins/opengraph/plugin.php
index e8cfa57a..c781585c 100644
--- a/bl-plugins/opengraph/plugin.php
+++ b/bl-plugins/opengraph/plugin.php
@@ -5,23 +5,6 @@ class pluginOpenGraph extends Plugin
public function init()
{
- // Fields and default values for the database of this plugin
- $this->dbFields = array(
- 'defaultImage' => ''
- );
- }
-
- public function form()
- {
- global $L;
-
- $html = '
';
- $html .= '';
- $html .= '';
- $html .= '' . $L->g('set-a-default-image-for-content') . '';
- $html .= '
';
-
- return $html;
}
public function siteHead()
@@ -88,8 +71,9 @@ class pluginOpenGraph extends Plugin
if ($src !== false) {
$og['image'] = $src;
} else {
- if (Text::isNotEmpty($this->getValue('defaultImage'))) {
- $og['image'] = $this->getValue('defaultImage');
+ $thumb = MediaHelper::getDefaultThumbnail();
+ if ($thumb != null) {
+ $og['image'] = $site->url() . "/" . $thumb->permalink();
}
}
}
diff --git a/bl-themes/defaultTheme/css/style.css b/bl-themes/defaultTheme/css/style.css
index 45599001..8053ff00 100755
--- a/bl-themes/defaultTheme/css/style.css
+++ b/bl-themes/defaultTheme/css/style.css
@@ -513,9 +513,11 @@ table tbody tr:last-child th:last-child {
}
.cover-image {
+ display: block;
max-width: 100%;
border-radius: 16px;
height: auto;
+ margin: auto;
}
.article-metadata {
diff --git a/bl-themes/defaultTheme/php/head.php b/bl-themes/defaultTheme/php/head.php
index e32a64b0..c9806611 100644
--- a/bl-themes/defaultTheme/php/head.php
+++ b/bl-themes/defaultTheme/php/head.php
@@ -39,6 +39,13 @@
}
+ smallThumb()): ?>
+ .cover-image {
+ max-height:200px;
+ width: 100%;
+ object-fit: cover;
+ }
+
diff --git a/bl-themes/defaultTheme/php/home.php b/bl-themes/defaultTheme/php/home.php
index 71c78e3a..0ae89d67 100644
--- a/bl-themes/defaultTheme/php/home.php
+++ b/bl-themes/defaultTheme/php/home.php
@@ -22,6 +22,10 @@
coverImage()) : ?>
+
+ showDefaultThumbnail() == true): ?>
+
+
diff --git a/bl-themes/defaultTheme/plugin.php b/bl-themes/defaultTheme/plugin.php
index 40ff11a5..7fbb51b4 100644
--- a/bl-themes/defaultTheme/plugin.php
+++ b/bl-themes/defaultTheme/plugin.php
@@ -6,12 +6,13 @@ class defaultTheme extends Plugin
public function init()
{
$this->dbFields = array(
- 'showPostInformation' => false,
+ 'showDefaultThumbnail' => false,
'dateFormat' => 'relative',
'accentColor' => 'default',
'background' => '',
'backgroundTiled' => true,
'banner' => '',
+ 'smallThumb' => false,
'bannerTiled' => false
);
}
@@ -25,7 +26,8 @@ class defaultTheme extends Plugin
$html .= PluginSettings::medias($this, 'banner', 'Banner background');
$html .= PluginSettings::bool($this, 'bannerTiled', 'Tiled Banner background');
- $html .= PluginSettings::bool($this, 'showPostInformation', 'Show Post Information');
+ $html .= PluginSettings::bool($this, 'showDefaultThumbnail', 'Show Default Thumbnail');
+ $html .= PluginSettings::bool($this, 'smallThumb', 'Small Thumbnail');
$html .= PluginSettings::values($this,'dateFormat', 'Date format', ['noshow'=>'No show', 'relative'=>'Relative', 'absolute'=>'Absolute'], 'Change the date format for the main page.');
$html .= PluginSettings::values($this,'accentColor', 'Accent Color', [
'default'=>'Blue',
@@ -45,9 +47,14 @@ class defaultTheme extends Plugin
return $html;
}
- public function showPostInformation()
+ public function smallThumb()
{
- return $this->getValue('showPostInformation');
+ return $this->getValue('smallThumb');
+ }
+
+ public function showDefaultThumbnail()
+ {
+ return $this->getValue('showDefaultThumbnail');
}
public function dateFormat()