Johan Broddfelt
/* Comments on code */

Image and video in posts

First of all I need a new column in my post table. I'll call it embed. This is where I will store the image or video-tag that should be added on top of my post.

ALTER TABLE `post` ADD `embed` TEXT NOT NULL AFTER `message`;

Then I just need to add the code that displays my embedded item in my post page.

// views/post/item.php
if ($obj->publish == '0000-00-00 00:00:00' and $user->status < 3) {

$headerData->title = $obj->title;
$headerData->description = $obj->summary;
$headerData->keywords = $obj->tags;

<div style="padding: 0px;">
    <!--<div style="position: absolute; margin-top: 20px; margin-left: 20px; font-size: 20px;">Test text</div>-->
    <?php echo $obj->embed; ?>
    <!--<img src="graphics/banner.png" style="margin-left:-20px; margin-top: -20px; width: 898px;">-->
    <h1><?php echo $obj->title; ?></h1>
    <p><?php echo $obj->message; ?></p>
    <p><i><?php echo $obj->posted; ?> - 
    <?php echo $obj->tags; ?></i></p>

<div class="topic_navigation">

I added the additional div with padding set to zero. This is because I want the image to fill the space all the way out to the borders.
And that is it. Now I can add an image like <img src="path/file.jpg" style="width: 100%;"> and it will fill the top of my post. The same goes for video make sure that it fills 100% of the width.

- Framework, PHP, media

Follow using RSS

<< Administration pages Modifying the list and edit forms >>


Mail (Not public)
Send mail uppdates on new comments
0 comment