Textpattern Forum

You are not logged in. Register | Login | Help

#11 2011-06-27 20:13:21

jakob
Moderator
From: Germany
Registered: 2005-01-20
Posts: 1,916
Website

Re: Image name instead ID in html

Claire, if you’re on txp 4.30+, you should be able to replace all your txp:variables with txp:image_info so you end up with:

<txp:images category="galerie" break="" pageby="limit" limit="12">

  <a href="<txp:site_url />images/<txp:image_info type="id" />/<txp:image_info type="name" />" 
     title="<txp:image_info type="caption" />" 
     rel="lightbox-galerie">
    <img width="<txp:image_info type="thumb_w" />" 
         height="<txp:image_info type="thumb_h" />" 
         title="<txp:image_info type="caption" />" 
         alt="<txp:image_info type="alt" />" 
         src="<txp:site_url />images/<txp:image_info type="id" />t/<txp:image_info type="name" />" />
  </a>

</txp:images>

TXP Builders – finely-crafted code, design and txp

Offline

#12 2011-06-27 20:53:02

CeBe
Plugin Author
From: Caen - Fr
Registered: 2010-06-25
Posts: 289
Website

Re: Image name instead ID in html

jakob a écrit:

you should be able to replace all your txp:variables with txp:image_info

Ah, yes ! That was the clever thing I’ve been looking for :)
Works perfectly, thank you !

Offline

#13 2012-03-12 22:00:48

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

Re: Image name instead ID in html

Hi this is really great.
I have a question about nested folders inside the images folder.
I’m using fpx image import to batch upload and automatically generate categories.
So the folder structure is like this:

images > import > category
Is there a way i can modify the images folder htaccess file so that it works with the nested folders.
Thanks a mill


its a bad hen that wont scratch itself.
photogallery

Offline

#14 2012-03-12 23:54:04

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,189
Website

Re: Image name instead ID in html

I thought fpx image import moved the files to the images directory.


My Plugins

Piwik Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#15 2012-03-13 02:06:28

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

Re: Image name instead ID in html

hi matt. you’re right… sorry. not sure what the problem is then… I will take another look at.


its a bad hen that wont scratch itself.
photogallery

Offline

#16 2012-03-13 23:42:31

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

Re: Image name instead ID in html

ah awesome working now. I’m just outputting a simple list of images like this:

<txp:images category="sligo" break="" wraptag="ul" sort="id asc"  >
<li class="imagelist" >  
<img title="<txp:image_info type="caption" />" alt="<txp:image_info type="alt" />" 
src="<txp:site_url />images/<txp:image_info type="id" />/<txp:image_info type="name" />" /></li>
<li class="imageinfo"><txp:image_info type="caption" /></li>
</txp:images>

That is in an article. Now that I look at it I guess it should be more like this.

<txp:images category="sligo" break="li" wraptag="ul" sort="id asc" form="imagelist" />

Even that seems like it shouldn’t be in an article…

Anyway I’m going to switch the main gallery of my photo blog over to this now. It is a modified version of the widescreen template so it uses a custom field instead of the article image field. The custom field has the same image id/function as an article image would. I know it’s a long shot but is there a way i could get away with still using the custom field instead of an article image within the images tag. There are hundreds of articles to change over so I thought i would ask first.

Here is the existing form:

<li><a href="<txp:permlink />" title="<txp:title />">
<img src="<txp:site_url />
images/<txp:custom_field name="Image-ID" />t.jpg" 
alt="Thumbnail of <txp:title />" /></a>

thanks

Last edited by kvnmcwebn (2012-03-13 23:46:45)


its a bad hen that wont scratch itself.
photogallery

Offline

#17 2012-05-04 15:01:30

maniqui
Moderator
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 2,989
Website

Re: Image name instead ID in html

This is an improved (I think!) version of the .htaccess trick that works well with smd_thumbnail (which creates subfolders to store images for each thumbnail profile).

I recommend to put this in an .htaccess file inside the your images folder. This way, by not putting it on your general .htaccess (the one at the root of your website), you avoid the rules being run on every request.

RewriteEngine On

# Uncomment one of the following lines in GoDaddy (depending from where you are serving images)
#RewriteBase /images/
#RewriteBase /static/images/

# Matches any URL of the kind /images/123/string.jpg and rewrites it internally to /images/123.jpg
RewriteRule ^([0-9]+)/(.+)(png|gif|jpg|bmp)$ $1.$3 [NC,L]

# Similarly to the above one, but this one matches those URLS that are in a subfolder like: /images/square/123/string.jpg 
# and rewrites them to /images/square/123.jpg
RewriteRule ^([^/]+)/([0-9]+)/(.+)(png|gif|jpg|bmp)$ $1/$2.$4 [NC,L]

I couldn’t find a way to merge the two rewrite rules into one, maybe someone clever than me could take it to that next level…


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#18 2014-07-15 13:36:14

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,018
Website

Re: Image name instead ID in html

Hi ;)

Very nice and useful tip! Thanks lot.

It seems that some bots (Google) try to smell into all Directories included in URLs. To avoid access to /images/1/ folder here is some changes:

# Protect this directory from direct access
ErrorDocument 401 default
# Enable rewrite
RewriteEngine On
# Set the current base URL
RewriteBase /images/
# Matches any URL of the kind /images/123/string.jpg and rewrites it internally to /images/123.jpg
RewriteRule ^([0-9]+)/(.+)(png|gif|jpg|bmp)$ $1.$3 [NC,L]
# Similarly to the above one, but this one matches those URLS that are in a subfolder like: /images/square/123/string.jpg 
# and rewrites them to /images/square/123.jpg
RewriteRule ^([^/]+)/([0-9]+)/(.+)(png|gif|jpg|bmp)$ $1/$2.$4 [NC,L]
# Restaure TXP 404 page for all other access
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Patrick.
Txp Tricks & Tips by french users : http://txp-fr.net | G+
Alison: a CSS Grid tool for all browsers

Offline

Board footer

Powered by FluxBB