Fetch Cover Image in Plugin (Solved)

Post Reply
User avatar
rizqijune
Jr. Bludit
Posts: 6
Joined: Sat Dec 03, 2022 1:05 am
Location: Indonesia
Has thanked: 4 times
Been thanked: 1 time

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

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;
	}
and this is my featured.php

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; ?>
Tell me if you need more informations
  • 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
Screenshot :
Image
Image
I dont post my full code to make this post easier to read :D
Last edited by rizqijune on Thu Feb 15, 2024 12:08 pm, edited 1 time in total.
Another Script Kiddie :geek:
User avatar
rizqijune
Jr. Bludit
Posts: 6
Joined: Sat Dec 03, 2022 1:05 am
Location: Indonesia
Has thanked: 4 times
Been thanked: 1 time

My bad. I forgot to add the cover image for the sticky content! :lol:
Another Script Kiddie :geek:
Post Reply