Extract first image from my post to display on the Ditty Posts Ticker
-
Hi,
Ditty Posts Ticker (DPT) is by far, the best plugin that i have bought. Thank You so much for creating this.
I have a question. I would like for my DPT to extract the first image from my post to be displayed on DPT.
I tried the code below, but it can’t seem to work :
function get_first_image() {
global $post, $posts;
$first_img = ”;
ob_start();
ob_end_clean();
$output = preg_match_all(‘/<img.+src=[\'”]([^\'”]+)[\'”].*>/i’, $post->post_content, $matches);
$first_img = $matches [1] [0];
if(empty($first_img)){ //Defines a default image
$first_img = “/images/default.jpg”;
}
return $first_img;
}<?php echo get_first_image() ?>
I am guessing that i need to find the correct path to the extract thumbnail.
I really not that good in html codes. Could you help, Please?
Thank You.
- The topic ‘Extract first image from my post to display on the Ditty Posts Ticker’ is closed to new replies.