Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can i change the filename when save (via browser) ? #109

Open
maykelesser opened this issue Jul 29, 2014 · 1 comment
Open

Can i change the filename when save (via browser) ? #109

maykelesser opened this issue Jul 29, 2014 · 1 comment

Comments

@maykelesser
Copy link

This is a request from a client of mine. For SEO purposes, somehow the file name to save the generated thumbnail is bothering him (when he save via browser).

I'm running the script generating the image using the following URL:

http://generacbrasil.com.br/common/function/thumb.php?url=testing-image.png&width=350&height=350&prefix=thm

But when I ask to save the image on my desktop for example, the name of the image you are saving is always "thumb.png".

Is there any way to save the image with its original name, or at least transform into thm_testing-image.png?
captura de tela 2014-07-29 as 13 27 55

@mikealmond
Copy link
Contributor

There really isn't anything you can do on the PHPThumb side for this. You could do a url rewrite so that /images/350/350/testing-image.png rewrites to /common/function/thumb.php?url=testing-image.png&width=350&height=350. That way the browser would try to save the file as testing-image.png and not thumb.png

In Apache it would look like this

# .htacecss
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^images/([1-9][0-9]{1,2})/([1-9][0-9]{1,2})/(.+)\.(jpg|png|jpeg)$ /common/function/thumb.php?url=$3.$4&width=$1&height=$2&prefix=thm [L]
</IfModule>

This would limit the width and height to the range 10...999 and the image extensions to either jpg, jpeg, or png.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants