PDA

View Full Version : Avatar Resizing


m002.p
07-19-2012, 05:08 PM
Hi guys,

Have a weird one here but I want to resize an avatar displayed using %. However, when doing it with the below method the image does not display.

<a href="profile.php?{$session[sessionurl]}do=editavatar"><img src="/forum/image.php?u={$bbuserinfo['userid']}" width="30%" height="30%"></a>

So, if this cant be solved, I was hoping it could be done with an edit to image.php allowing the use of height & width. For example:

/image.php?u=45&height=30%&width=30%

Any ideas how I can get either to work?

Matt

kh99
07-19-2012, 07:06 PM
It seems to me like the first code you posted works. I'm not an html expert, but I think 30% could mean a different thing depending on where you put the code. Also, if a user has no avatar the image will be blank.

m002.p
07-19-2012, 07:28 PM
Hi,

Thanks for your reply.

The code is used in a template on the forumhome.

The image with the first code simply does not show whereas change it to a pixel ie. width="200" works. It seems to be a problem with the percentage for the img tag.

peterska2
07-19-2012, 10:13 PM
Hi guys,

Have a weird one here but I want to resize an avatar displayed using %. However, when doing it with the below method the image does not display.

<a href="profile.php?{$session[sessionurl]}do=editavatar"><img src="/forum/image.php?u={$bbuserinfo['userid']}" width="30%" height="30%"></a>

So, if this cant be solved, I was hoping it could be done with an edit to image.php allowing the use of height & width. For example:

/image.php?u=45&height=30%&width=30%

Any ideas how I can get either to work?

Matt

I don't see any reason why the first one wouldn't work, but IIRC percentages and divs don't tend to play nice so might need to stick a single cell table in there. You shouldn't have { and } in vB3 templates either.

Try

<table border="0" cellpadding="0" cellspacing="0"><tr><td><a href="profile.php?$session[sessionurl]do=editavatar"><img src="/forum/image.php?u=$bbuserinfo[userid]" width="30%" height="30%"></a></td></tr></table>

Should do the trick if memory serves me correctly

Of course, this is working on the assumption that you already have the avatar displaying on forumhome without any resizing taking place.

kh99
07-19-2012, 10:25 PM
...You shouldn't have { and } in vB3 templates either.

The curly braces are php "complex syntax", it allows you to use more "complex" variables in a string, like an array element with the key in quotes.

peterska2
07-19-2012, 10:29 PM
The curly braces are php "complex syntax", it allows you to use more "complex" variables in a string, like an array element with the key in quotes.
Yes, they are :) but they still don't belong there in this case ;)

kh99
07-19-2012, 10:50 PM
Yes, they are :) but they still don't belong there in this case ;)

Not to make a big deal out of it, but I disagree - they "belong" there in the original code because there are quotes around the array key and it wouldn't work without the curly braces. You can remove the quotes as you did, but it doesn't mean the original code was wrong. Also, there are some situations where there's no other way to insert a variable, such as a multi-dimension array, an object, or if adjacent characters in the string would cause ambiguity. ;)

m002.p
07-20-2012, 06:58 AM
Sorry to say but that code doesnt work either. The avatar simply does not display...

Cant get my head round it... change the height & width to pixels and it works fine.

Furthermore, no. The avatar does not already display on the forumhome Peterska. I am adding a welcome tempate to the top of the forumhome in vb3.

My only option may be hard coding it into the image.php file?

kh99
07-20-2012, 10:36 AM
Which browser are you using? Can you show us a little more of the code around where you're putting it?

I don't think changing image.php would work because it wouldn't have any way to know what "30%" meant, and even if it did you would need to call a funciton to resize the mage.

m002.p
07-20-2012, 07:56 PM
Yes here is the template. It is a modification of a welcome panel here on vb.org

<if condition="$vbulletin->options['onoff']">
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
<td class="tcat" colspan="3" align="left">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('forumhome_welcomepanel')"><img id="collapseimg_forumhome_welcomepanel" src="$stylevar[imgdir_button]/collapse_tcat$vbcollapse[collapseimg_welcome_panel].gif" alt="" border="0" /></a>
<phrase 1="{$bbuserinfo['username']}">$vbphrase[wp_welcomeback]</phrase>
</td>
</tr>
<tbody id="collapseobj_forumhome_welcomepanel" style="$vbcollapse[collapseobj_forumhome_welcomepanel]">
<tr>
<td class="alt1" align="center" width="1%">
<table border="0" cellpadding="0" cellspacing="0"><tr><td><a href="profile.php?$session[sessionurl]do=editavatar"><img src="/forum/image.php?u=$bbuserinfo[userid]" width="30%" height="30%"></a></td></tr></table>
</td>
<td width="50%" class="alt2" align="$stylevar[left]" valign="top">
<phrase 1="{$bbuserinfo['newposts']}" 2="{$bbuserinfo['newthreads']}" 3="{$bbuserinfo['lastvisit']}" 4="$timenow" 5="$datenow" 6="{$bbuserinfo['pmunread']}" 7="{$wp['newpostsplural']}" 8="{$wp['newthreadsplural']}">$vbphrase[wp_unread]</phrase>

<if condition="$vbulletin->options['rules']">
<br /><br />
<phrase 1="$vboptions[ruleid]">$vbphrase[wp_rules]</phrase>
</if>

<if condition="$vbulletin->options['showlatestannouncement']">
<br /><if condition="!$vbulletin->options['rules']"><br /></if>
<table border="0"><tr><td><img src="/forum/images/icons/icon4.gif"></td>
<td>
<phrase 1="$wp_forum_title" 2="$wp_latest_a_link" 3="$wp_latest_a_title">$vbphrase[wp_latestannouncement]</phrase>
</td>
</tr>
</table>
</if>


</td>
<td width="50%" class="alt1" align="$stylevar[left]" valign="top">
<phrase 1="{$bbuserinfo['posts']}" 2="$wp_user_thread_count" 3="{$bbuserinfo['postsperday']}" 4="{$bbuserinfo['postpercent']}">$vbphrase[wp_user_stats]</phrase>
<if condition="$bbuserinfo[active]">
<b>&raquo;</b> $vbphrase[wp_activity] <a href="forumdisplay.php?{$session[sessionurl]}f={$bbuserinfo[active][0][forumid]}">{$bbuserinfo[active][0][title]}</a> $vbphrase[wp_activity2] <b>{$bbuserinfo[active][1]}</b> $vbphrase[wp_activity3].<br />
<else />
$vbphrase[wp_activity] <i>N/A</i><br />
</if>

<!--BEGIN VB STATUS-->
<if condition="$vbulletin->options['vbstatus_active']">
<if condition="$bbuserinfo[vbstatus_status]">
<font size="1">$bbuserinfo[musername] {$vbulletin->options['vbstatus_statusprefix']}</font>
<em id="vbstatus_$bbuserinfo[userid]">
<font size="1"><i>$bbuserinfo[vbstatus_status]</i></font>
<if condition="$bbuserinfo['userid']==$userinfo['userid'] OR is_member_of($bbuserinfo, 9, 10, 11)">
<a href="javascript:Att_Ajax('userid=$bbuserinfo[userid]&postid=$bbuserinfo[userid]','vbstatus/vbstatus_ajax.php')"><font size="1">Edit</font></a>

</if>
</em>
<else />
<if condition="$bbuserinfo['userid']==$bbuserinfo['userid']">
<br /><br /><a href="javascript:Att_Ajax('userid=$bbuserinfo[userid]&postid=$bbuserinfo[userid]','vbstatus/vbstatus_ajax.php')"><font size="1">Add New Status</font></a>

</if>
</if>
</if>
<!--END VB STATUS-->
<br /><br />

</td>
</tr>
</tbody>
</table>
<br />
</if>

You can see the code in question near the top.

Well it would sure be possible to send just the GET vars to the php file to then add the % in the variable outputs in the php code?

kh99
07-20-2012, 08:09 PM
Again, I'm not really an html person, but the <td> tag you have it inside has a width="1%", so wouldn't that make it very small? When you put in width="200" that might force it to be at least 200 pixels, but maybe the 30% of 1% is just too small to see anything?

m002.p
07-20-2012, 08:37 PM
You are absolutely right. I am so sorry..I feel like an idiot.

Thank you for your time & effort.