Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 10-05-2011, 08:56 AM
danyxxx danyxxx is offline
 
Join Date: Oct 2010
Posts: 52
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default [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 !
Reply With Quote
  #2  
Old 10-07-2011, 12:34 AM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

$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.
Reply With Quote
  #3  
Old 10-07-2011, 05:41 AM
danyxxx danyxxx is offline
 
Join Date: Oct 2010
Posts: 52
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Maybe for '180px' if the condition contain text we will make the value with text to : 180px
So?
Reply With Quote
  #4  
Old 10-07-2011, 09:23 AM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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"';

Reply With Quote
  #5  
Old 10-07-2011, 12:43 PM
danyxxx danyxxx is offline
 
Join Date: Oct 2010
Posts: 52
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

doesn't work
Reply With Quote
  #6  
Old 10-07-2011, 03:17 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What hook are you using?
Reply With Quote
  #7  
Old 10-07-2011, 04:49 PM
danyxxx danyxxx is offline
 
Join Date: Oct 2010
Posts: 52
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

postbit_display_complete
Reply With Quote
  #8  
Old 10-07-2011, 07:17 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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"'

Reply With Quote
Благодарность от:
danyxxx
  #9  
Old 10-07-2011, 08:45 PM
danyxxx danyxxx is offline
 
Join Date: Oct 2010
Posts: 52
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OH MY GOD , you really really rullz this kind of things
Thanks a lot man !
(+thanks)
Reply With Quote
Благодарность от:
BirdOPrey5
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:54 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04238 seconds
  • Memory Usage 2,255KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (4)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (2)post_thanks_box_bit
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete