HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Please upgrade here. These earlier versions are no longer being updated and have security issues.

Calling the photo outside the forum software

PHP/mySQL is a hobby and not a profession. I've written a nice little site for a league I belong to with a custom database and using PHP and queries I can pull stats down and display them. The site has really grown over the years. I've always wanted to add a section for logged in people to upload photos and adjust profile but being conscious of security and of my lack of skill I never created this feature. I recently installed Vanilla forums and it easily fit into my site. I have been able to construct pages that pull up a vanilla user ID and a user ID from my database and display information from both databases. I spent a while on the photo when I realized the IMG src is different than the file name and I’ve discovered this is due to some kind of algorithm that I won’t be able to understand. I would like to be able to hook into this somehow or disable it. In effect, I want to be able to write a select statement against the vanilla database (using a connection file I created) and grab the photo URL – then take that and correctly display the photo. I did a bunch of searches but haven’t found much information. I was hoping someone could point me in the right direction. I played around with the XML and indeed there is a photo URL there but it goes to a very small copy of the photo (thumbnail). If I could get this to show the right photo I might be able to parse the xml and grab that value.

Tagged:

Best Answer

  • peregrineperegrine MVP
    edited April 2012 Accepted Answer

    try this

    Describe`GDN_User`
    
    you will see a column called photo that is matched with a userid.
    
    So if the username joe is userid 5
    
    you select on id 2
    SELECT photo
    FROM `GDN_User`
    WHERE `UserID` = "5"
    
    your result will be  a 3 digit directory followed by  about 12 characters then jpg.
    
    userpics/416/5XO93IOLVSY1.jpg
    
    parse the file name out 
    
    e.g.
    5XO93IOLVSY1.jpg
    
    
    append an n to the front if you want the thumbnail
    
    n5XO93IOLVSY1.jpg
    
    
    append a p to the front if you want the full size photo
    p5XO93IOLVSY1.jpg
    
    
    view it
    thumbnail
    http://"yourhosthere"/vanilla/uploads/userpics/416/n5XO93IOLVSY1.jpg
    
    fullsize
    http://"yourhosthere"/vanilla/uploads/userpics/416/p5XO93IOLVSY1.jpg
    

    if if you src it -

    1) give it a class and set width and height in css

    2) or directly place width and height statement in the src statement (the page w/picture will load faster the second way because the browser will know the widthand height)

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

    UnderDog422

Answers

  • peregrineperegrine MVP
    edited April 2012 Accepted Answer

    try this

    Describe`GDN_User`
    
    you will see a column called photo that is matched with a userid.
    
    So if the username joe is userid 5
    
    you select on id 2
    SELECT photo
    FROM `GDN_User`
    WHERE `UserID` = "5"
    
    your result will be  a 3 digit directory followed by  about 12 characters then jpg.
    
    userpics/416/5XO93IOLVSY1.jpg
    
    parse the file name out 
    
    e.g.
    5XO93IOLVSY1.jpg
    
    
    append an n to the front if you want the thumbnail
    
    n5XO93IOLVSY1.jpg
    
    
    append a p to the front if you want the full size photo
    p5XO93IOLVSY1.jpg
    
    
    view it
    thumbnail
    http://"yourhosthere"/vanilla/uploads/userpics/416/n5XO93IOLVSY1.jpg
    
    fullsize
    http://"yourhosthere"/vanilla/uploads/userpics/416/p5XO93IOLVSY1.jpg
    

    if if you src it -

    1) give it a class and set width and height in css

    2) or directly place width and height statement in the src statement (the page w/picture will load faster the second way because the browser will know the widthand height)

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

    UnderDog422
  • Brilliant! Thank you so much. The answer was much easier than I made it out to be!!

    Chanux
  • glad you "liked" it.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

    UnderDogChanux
  • The system is already in place! I've been wanting to do this for years and finally have it! Thank you!

  • http://www.northjerseypoker.com/v2/player-details.php?ppid=1

    The photo is from Vanilla, everything else is from my db

  • ToddTodd Chief Product Officer Vanilla Staff

    Awesome stuff.

    This user image trick actually causes a tonne of pain with imports and whatnot. So much so that we will most likely be changing things up and adding an Avatar column in our next release.

Sign In or Register to comment.