Results 1 to 4 of 4
-
5th Aug 2011, 06:39 PM #1OPMember
First Image Function
Hi ...
I was trying the below function to display only the first image from the content on the index page.
Function :
PHP Code:function catch_that_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;
}
Can someone tell me whats wrong with this function ??Matrix4u Reviewed by Matrix4u on . First Image Function Hi ... I was trying the below function to display only the first image from the content on the index page. Function : function catch_that_image() { global $post, $posts; $first_img = ''; ob_start(); ob_end_clean(); Rating: 5
-
5th Aug 2011, 07:40 PM #2MemberWebsite's:
tehMoviez.com 0Senes.com GeekFaceGames.comchange
Code:return $first_img;
Code:return "<img src=\"{$first_img}\" />";
JokerHacker Blog
JokerHacker PHP coding Service // back again!
CurlAxel PHP Download Accelerator
hardly remembering the milk :p
-
6th Aug 2011, 06:38 AM #3OPMember
Thanks Mate ...
Worked Like a Charm
-
6th Aug 2011, 05:08 PM #4MemberWebsite's:
tehMoviez.com 0Senes.com GeekFaceGames.comany time mate
JokerHacker Blog
JokerHacker PHP coding Service // back again!
CurlAxel PHP Download Accelerator
hardly remembering the milk :p
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
[PHP] }else{ Function 3 parts
By viruz99 in forum Web Application/Script SupportReplies: 4Last Post: 17th Jan 2012, 01:33 AM -
[Help] Fix PHP function
By m1rr0z in forum Web Development AreaReplies: 0Last Post: 15th Apr 2011, 09:40 AM -
Kloxo zip function. Need help.
By tres in forum Webmaster ResourcesReplies: 0Last Post: 12th Nov 2010, 09:59 AM -
[php] list_files() function
By natsu90 in forum Web Development AreaReplies: 2Last Post: 29th Sep 2010, 08:23 AM -
PHP Function (Link_Maker)
By litewarez in forum Webmaster ResourcesReplies: 0Last Post: 2nd Dec 2008, 01:28 AM
themaLeecher - leech and manage...
Version 5.03 released. Open older version (or...