jpg, png and gif check jpg, png and gif check
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

jpg, png and gif check

Started by nickfzx, November 14, 2006, 09:09:27 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

nickfzx

Hey

So one last thing ;)

So I would like to get the avatars to work in punbb, in you initial post when you just made the bridge you said:

QuoteAvatars... prepared but not implemented. You shouldn't enable avatars in CPG. However you can eg modify the function theme_html_comments... and check for jpg, gif, png, and if found, display the avatar. You only need to do this check, the avatar path and the name is already available

so I would like to do this:  here is the relevant part of theme_html_comments:

if($cpg_udb->can_join()){
if ($CONFIG['enable_avatar']){
        ($row['avatar_url'] != "") ? $avatar_url= "<img src='".AVATAR_PATH.$row["avatar_url"]."' class='image' style='float: left; margin-right: 5px;' alt='' />" : $avatar_url = '';
}
else $avatar_url="";
} else { // only used when tables can't be joined... then we need to query for the avatar URL -> function get_avatar
if ($CONFIG['enable_avatar']){
$result2 = $cpg_udb->get_avatar($row['author_id']);
$avatar_url= preg_replace('/\/\//','/',AVATAR_PATH.$result2["avatar_url"]);
        ($result2['avatar_url'] != "") ? $avatar_url= "<img src='".$avatar_url."' class='image' style='float: left; margin-right: 5px;' alt='' />" : $avatar_url = '';
}
else $avatar_url="";
}


So I need to add the jpg, png and gif file extension check to this code somewhere right?

Which section is used by punbb, the if or else part?

Cheers

Nick

nickfzx

are I find it is the first if statement.

If i stick .jpg after the avatar url bit all the avatars that are jpegs show up.

So i need to somehow put something that checks file extensions here....I'll search around google a bit for a way of doing this.

Cheers

Nick

nickfzx

so i have done it and tested it...(i had a little help from the guys over on www.dreamincode.net)

so if anyone else wants to get avatars working with coppermine bridged to punbb you will need to replace this code:

if ($CONFIG['enable_avatar']){
($row['avatar_url'] != "") ? $avatar_url= "<img src='".AVATAR_PATH.$row["avatar_url"].'.gif'"' class='image' style='float: left; margin-right: 5px;' alt='' />" : $avatar_url = '';
}


with this code:
   if ($CONFIG['enable_avatar']){
if ( file_exists(AVATAR_PATH . $row['avatar_url'] . '.jpg' ) ){
($row['avatar_url'] != "") ? $avatar_url= "<img src='".AVATAR_PATH.$row["avatar_url"].".jpg' class='image' style='float: left; margin-right: 5px;' alt='' />" : $avatar_url = '';
            }
else if ( file_exists(AVATAR_PATH . $row['avatar_url'] . '.png' ) ){
($row['avatar_url'] != "") ? $avatar_url= "<img src='".AVATAR_PATH.$row["avatar_url"].".png' class='image' style='float: left; margin-right: 5px;' alt='' />" : $avatar_url = '';
            }
else if ( file_exists(AVATAR_PATH . $row['avatar_url'] . '.gif' ) ){
($row['avatar_url'] != "") ? $avatar_url= "<img src='".AVATAR_PATH.$row["avatar_url"].".gif' class='image' style='float: left; margin-right: 5px;' alt='' />" : $avatar_url = '';
            }
}



In the file... themes.inc.php (of course you will need stramm's modpack)


for an example of it working now that has comments with avatars that are both gif and jpg:

http://amateurillustrator.com.s2734.gridserver.com/galleries/displayimage.php?pos=-1033

i can't guarantee that this example will stay here. but I will soon be updating my main gallery (see my signature for link) to have this feature.


thanks for all your help stramm and hope this helps some people...maybe you could add it to your modpack?

cheers

Nick

nickfzx

after a bit more testing i found a little bug

if someone comments who has an avatar then somone comments who doesn't have an avatar the avatar from the fist poster will be used.

This problem isn't visible if everyone has avatars or if the person without the avatar comments first.

I will fix this and post my changed code here.

Stramm

not tested...

   if ($CONFIG['enable_avatar'] && $row['avatar_url'] != ""){
if ( file_exists(AVATAR_PATH . $row['avatar_url'] . '.jpg' ) ){
$avatar_url= "<img src='".AVATAR_PATH.$row["avatar_url"].".jpg' class='image' style='float: left; margin-right: 5px;' alt='' />";
            }
else if ( file_exists(AVATAR_PATH . $row['avatar_url'] . '.png' ) ){
$avatar_url= "<img src='".AVATAR_PATH.$row["avatar_url"].".png' class='image' style='float: left; margin-right: 5px;' alt='' />";
            }
else if ( file_exists(AVATAR_PATH . $row['avatar_url'] . '.gif' ) ){
$avatar_url= "<img src='".AVATAR_PATH.$row["avatar_url"].".gif' class='image' style='float: left; margin-right: 5px;' alt='' />";
            }
else $avatar_url="";
}
else $avatar_url="";

nickfzx

yep that's done it...seems to work now in all cases i can see.


here is an example:
http://amateurillustrator.com.s2734.gridserver.com/galleries/displayimage.php?album=lastcom&cat=1&pos=90

anyone reading this ignore my code, stramm's is the correct one :)

cheers

Nick