MyBB Community Forums
[How To?] Broken Avatar in custom page - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: 1.8 Support (https://community.mybb.com/forum-175.html)
+--- Forum: General Support (https://community.mybb.com/forum-176.html)
+--- Thread: [How To?] Broken Avatar in custom page (/thread-227256.html)

Pages: 1 2


Broken Avatar in custom page - ShadowOne - 2020-04-11

Hello I have a problem with a custom page. I created a custom directory "X" in my forum root and inside the directory I created a custom page "Y.php" that includes global.php:

require_once "../global.php";

How is that users avatar appear broken when I browse the page?
In particular, the URL being outputted is the following:

src="./uploads/avatars/avatar_1.gif?dateline=1534416144"

Am I missing something or did something wrong?


RE: Broken Avatar in custom page - .m. - 2020-04-11

what is the code used for getting user avatar ?

if custom php file is in a sub-folder then avatar link should be like
src="../uploads/avatars/avatar_1.gif?dateline=1534416144"



RE: Broken Avatar in custom page - ShadowOne - 2020-04-13

(2020-04-11, 02:59 AM).m. Wrote: what is the code used for getting user avatar ?

if custom php file is in a sub-folder then avatar link should be like
src="../uploads/avatars/avatar_1.gif?dateline=1534416144"

I'm using this piece of code inside the custom page:

<?php 
add_breadcrumb("Custom Page", "custom.php");
eval("\$html = \"".$templates->get("_custom.php")."\";");
output_page($html);
?>

The global template mentioned contains just this:

<head>
 <title>Site</title>
 {$headerinclude}
 {$extraheaderinclude}
</head>
<body>
 {$header}



Guess I should alter the avatar variable like this:

$mybb->user['avatar'] = '.'.$mybb->user['avatar'];

But I cannot understand where this should be placed


RE: Broken Avatar in custom page - Crazycat - 2020-04-14

You can put that before the eval line


RE: Broken Avatar in custom page - ShadowOne - 2020-04-14

(2020-04-14, 06:23 AM)Crazycat Wrote: You can put that before the eval line

Just did so, but it didn't work Sad


RE: Broken Avatar in custom page - Crazycat - 2020-04-14

Peharps with the full content of your php file I can help you. But working with 4 lines is impossible.


RE: Broken Avatar in custom page - ShadowOne - 2020-04-14

(2020-04-14, 10:58 AM)Crazycat Wrote: Peharps with the full content of your php file I can help you. But working with 4 lines is impossible.

I believe the problem originates from the theme I'm using, but looks so strange as I'm trying to change a MyBB variable by hardcoding it into the page.

About full content, the only other thing I have in that page is the one below. I use it to understand if user has permission to read it depending on usergroups:

<?php 
define("IN_MYBB", 1);
require_once "../global.php";
$groups = $mybb->user['usergroup'];
if($mybb->user['additionalgroups'])
{
$groups.= "," . $mybb->user['additionalgroups'];
}
$explodedgroups = explode(",", $groups);
$canview  = 0;
$allowedgroups = array(4);
foreach($explodedgroups as $group)
{
if(in_array($group, $allowedgroups))
{
$canview = 1;
break;
echo'{$headerinclude}{$header}';
}
}
if(!$canview)
{
echo'<meta http-equiv="refresh" content="0;url=https://boardurl.com" />';
error_no_permission();
}
?>



RE: Broken Avatar in custom page - Omar G. - 2020-04-14

Please past your theme details, as it seems to me your theme is outputting an avatar the MyBB core doesn't by default.

Also attach an image where the avatar is displayed correct please.


RE: Broken Avatar in custom page - ShadowOne - 2020-04-15

(2020-04-14, 07:10 PM)Omar G. Wrote: Please past your theme details, as it seems to me your theme is outputting an avatar the MyBB core doesn't by default.

Also attach an image where the avatar is displayed correct please.

This is the theme I'm using: https://community.mybb.com/thread-224006.html
What kind of details should I post?

EDIT: Just realized that it only happens with MY avatar.. in fact as Admin I've placed a default avatar to all users and removed the ability to upload other ones. The avatar I set as default to all users doesn't get broken (it has its own full image url ending in .png which loads correctly) while my own avatar is a .gif I uploaded via usercp.


RE: Broken Avatar in custom page - Omar G. - 2020-04-15

But is your avatar broken only in the new created page or it is broken in any page?

Users have reported issues with GIF images before.