Forum Moderators: phranque
Thumbs always start with the letter t...
my_images/username/album_id/image1.jpg needs to be rewritten but...
my_images/username/album_id/timage1.jpg must not be.
How do I test for this?
I know below is wrong... but you can see what I am trying to do...
RewriteCond %{REQUEST_FILENAME}
RewriteRule .!^t*\.(jpe?g¦gif¦bmp¦png)$ myscript.php?src=%{REQUEST_FILENAME} [L]
Thanks gurus.
- Call the script only if it is an image being requested.
- Do not watermark for images where final part of URL begins t-.
- Question: are all the images in one folder, or are their multiple branches and/or multiple levels?
Personally, I'd have thumbnails in one folder and main images in another.
Are the main images numbered? If so, it is easy to differentiate 234567.jpg and t234567.jpg. If named and not numbered, I would be cautious in using just 'starts with t' as a criteria. I'd use 't-' to be sure the file really is a thumbnail.
What other requirements are there?
# Rewrite if final requested URL-path-part starts with letter except for 't', contains zero or more additional
# letters, followed by one or more numbers, and ends with image filetype, preserving directory-path (if any).
RewriteRule ^(([^/]+/)*[a-su-z][a-z]*[0-9]+\.(jpe?g¦gif¦bmp¦png))$ myscript.php?src=$1 [L]
# Rewrite if final requested URL-path-part starts with all-letters, followed by one or more numbers, and
# ends with image filetype, preserving directory-path (if any). Note that "t-" thumbnails are excluded.
RewriteRule ^(([^/]+/)*[a-z]+[0-9]+\.(jpe?g¦gif¦bmp¦png))$ myscript.php?src=$1 [L]
# Rewrite if final requested URL-path-part starts with "album_id", followed by all-letters,
# followed by one or more numbers, and ends with image filetype, preserving additional
# directory-path (if any). Note that "t-" thumbnails are excluded.
RewriteRule ^(([^/]+/)*album_id/[a-z]+[0-9]+\.(jpe?g¦gif¦bmp¦png))$ myscript.php?src=$1 [L]
If you're accepting user-generated content, then the same pattern and URL-specification can (and should) be used in 'screening' user-created filenames, so that you won't accept a user-created filename that cannot be properly rewritten.
Replace all broken pipe "¦" characters in code found on this forum with solid pipes before use; Posting on this forum modifies the pipe characters.
Jim