Fetch Cover Image in Plugin (Solved)
Posted: Wed Feb 14, 2024 5:31 am
How to fetch cover image in plugin?
It's working in my page.php theme. But in plugin it is not generating anything. I tried to add "test" to src image to make sure.
Am I missing something?
This is my plugin.php
and this is my featured.php
Tell me if you need more informations
It's working in my page.php theme. But in plugin it is not generating anything. I tried to add "test" to src image to make sure.
Am I missing something?
This is my plugin.php
Code: Select all
public function showFeatured()
{
global $L;
global $pages;
global $Page;
if ($this->getValue('featured') == true) {
include ($this->phpPath().'php/components/featured.php');
} else {
$html = "false";
}
return $html;
}
Code: Select all
<?php
$stickyPageKeys = $pages->getStickyDB();
foreach ($stickyPageKeys as $pageKey):
$page = new Page($pageKey);
$title = $page->title();
$link = $page->permalink();
$img = $page->coverImage();
$items = file_get_contents(PATH_PAGES . $pageKey . DS . FILENAME);
?>
<li class="splide__slide" style="height: 13rem;">
<a href="<?php echo $link; ?>">
<img src="<?php echo $img; ?> test"
style="display: block; -o-object-fit: cover; object-fit: cover; -o-object-position: center; object-position: center; width: 100%; height: 13rem;"
alt="<?php echo $title . ' image'; ?>">
</a>
</li>
<?php endforeach; ?>
- Version : Bludit 3.15.0
- PHP : PHP 8.2
- Theme : Riztail (My theme project)
- Plugin : Default Starter Plugin and custom theme plugin ($themePlugin)
- Javascript : Splide Carousel JS Version 4.1.4
I dont post my full code to make this post easier to read