vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   [SOLVED]Avatar width resize with condition (https://vborg.vbsupport.ru/showthread.php?t=271463)

danyxxx 10-05-2011 08:56 AM

[SOLVED]Avatar width resize with condition
 
Hello,

I'm looking for a modification like this:

if the avatar width is bigger than 180px -> resize to 180px

How can be made this without affect the width smaller than 180px ???
I try it this way -->

In 'add plugins' ->

PHP Code:

if($post['avwidth'] > '180')
{
  
$this->post['avwidth']  = 'width="180"';


But this modification , resize all avatars to 180px .
I want only the avatars that are bigger than 180px to be resized .
Please help because I don't know the language that can be used .... I used ">" for definition "bigger then" but I see that doesn't work .

Kind regards !

BirdOPrey5 10-07-2011 12:34 AM

$post['avwidth'] contains text, not just the number... You will have to use some php string functions to strip out everything but the number and then run the greater-than comparison.

danyxxx 10-07-2011 05:41 AM

Maybe for '180px' if the condition contain text we will make the value with text to : 180px
So?

BirdOPrey5 10-07-2011 09:23 AM

No, 'px' is not the issue.

$post['avwidth'] is NOT a number, It is the exact same value as $this->post['avwidth']. It is a "string" and therefore it is always greater than the string value 180 you are testing against.

There are several ways to extract just the number from that string, one way is with the "substr" function:

http://php.net/manual/en/function.substr.php

Look at the last example in example 2:

PHP Code:

$rest substr("abcdef", -3, -1); // returns "de" 

So try something like this:

PHP Code:


$avwidth 
substr($post['avwidth'], -7, -); //returns just the numerical width

if(intval($avwidth) > 180)
{
  
$this->post['avwidth']  = 'width="180"';



danyxxx 10-07-2011 12:43 PM

doesn't work :(

BirdOPrey5 10-07-2011 03:17 PM

What hook are you using?

danyxxx 10-07-2011 04:49 PM

postbit_display_complete

BirdOPrey5 10-07-2011 07:17 PM

Sorry, looks like I got the substr parameters wrong... this one should work, I tested it:L

PHP Code:

$avwidth substr($post['avwidth'], ); 
$avwidth substr($avwidth0, -);

if(
intval($avwidth) > 180

  
$this->post['avwidth']  = 'width="180"'



danyxxx 10-07-2011 08:45 PM

OH MY GOD , you really really rullz this kind of things :)
Thanks a lot man !
(+thanks)


All times are GMT. The time now is 04:08 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01132 seconds
  • Memory Usage 1,733KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete