1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

encode timthumb url

Discussion in 'PHP' started by Johnta, Jul 6, 2010.

  1. #1
    Hi all; Here is a problem that I have tried to solve for three days now but cannot work around :
    when I call timthumb on an Image I get the whole command line and its variables in the url of the Image Location like this,

    <img src="/scripts/timthumb.php?src=/images/whatever.jpg&w=150&h=200&zc=1" alt="" />
    HTML:
    timthumb resize the Image and save it by an encoded name in the cash directory, I want to assign the source attribute in the image tag to the encoded name not to the command but don't know how to hack the code to show the coded url .
    Anyone have tried this before or knows about it can help .. Thank you
     
    Johnta, Jul 6, 2010 IP
  2. AsHinE

    AsHinE Well-Known Member

    Messages:
    240
    Likes Received:
    8
    Best Answers:
    1
    Trophy Points:
    138
    #2
    You have to find how timthumb generates that encoded name and use the same algorithm to asign source of your images
     
    AsHinE, Jul 6, 2010 IP
  3. Johnta

    Johnta Peon

    Messages:
    101
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Ok... Problem Solved
    for anyone facing this problem , it can be solved by using .htaccess file
     
    Johnta, Jul 7, 2010 IP
  4. dannoll

    dannoll Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Johnta, I would be grateful if you could share the actual HTACCESS solution you applied. I have been searching for a while for a solution to the same TimThumb ugly URL problem.
     
    dannoll, Sep 7, 2010 IP
  5. Johnta

    Johnta Peon

    Messages:
    101
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Ok Non probs.

    Inside your script that generates the image , encode the generated url and add an extension like .png.
    send this encoded url to the script timthumb.php
    create .htaccess file in the timthumb folder to redirect the address from the one you have encoded to the one required by timthumb.php script.
    Inside the timthumb.php decode the coming url, explode it , then send its components to the script.

    Easy ..
     
    Johnta, Sep 8, 2010 IP
  6. dannoll

    dannoll Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks for the response. Not sure I understand completely:
    1) When you say "inside the script that generates the images, encode the URL" -- are you talking about inside the TimThumb php file?
    2) Why add a .png extension?

    I'd love to see your code...unfortunately I know a little, but not enough to do what you described.
     
    dannoll, Sep 8, 2010 IP
  7. Johnta

    Johnta Peon

    Messages:
    101
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    
    <img src=../thumb/' <? (Put the variables required by timthumb script here) encoded using base64_encode function ) . '.png'  ?> />
    Code (markup):
    Then, inside the thumb folder put this htaccess file

    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^([^_]*)\.png$ timthumb.php?src=$1 [L]
    </IfModule>
    Code (markup):
    Now inside the timthumb.php script explode the request and use its components as your variables.
     
    Johnta, Sep 8, 2010 IP
  8. cosmictap

    cosmictap Member

    Messages:
    23
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #8
    Sorry to necropost but I would just LOVE an elegant solution to this TimThumb SEO issue. TimThumb seems to be in almost every Wordpress theme I like, and it mangles the image URLs so badly that it surely has a negative SEO impact for people who want their images to show up in image search engines.

    If there's an easy way to fix this I'd be in your debt! :D
     
    cosmictap, Nov 19, 2011 IP