[Snippet] PageImage
#1
Posted 22 March 2007 - 11:37 PM
File Submitter: lloyd_borrett
File Submitted: 23 Mar 2007
File Updated: 26 May 2007
File Category: Images & Galleries
* ---------------------------
* Snippet: PageImage
* ---------------------------
* Version: 1.3
* Date: 2007-05-26
*
* Returns an image file tag associated with the current document.
* Alternatively, a document can be specified by passing the
* document id as parameter 'id', or alternatively, the
* parameter 'alias' can be used.
*
* Image filename takes the form <alias>.<image type> where
* <alias> is the alias of the page, and <image type> is the
* file extension for acceptable image file types
* (jpg, gif, pnp and jpeg).
*
* NOTE: If user friendly URLs aren't being used, then the snippet
* uses the page id, so the image filename becomes <pageid>.<image type>
*
* If no image is found for the current page, then we look for
* the image associated with the closest ancestor page
* unless recursive is set to [false|0].
*
* Usage: [!PageImage
*
* ?alias=<alias>
*
* &id=<doc id>
*
* &dir=<image directory>
* e.g. &dir=assets/images/pagepics/
* default is assets/images/pagepics/
*
* &class=[false|0] | someclass
* if not specified then img class isn't output
* if false|0 then the img class isn't output
*
* &div=[false|0] | someclass
* if not specified then div isn't output
* if false|0 then the div isn't output
*
* &recursive=[false|0]
* anything else equates to true (default)
*
* !]
*
* History:
* 2007-05-26, 1.3 Lloyd Borrett
* Fixed syntax bug
*
* 2007-03-23, 1.2 Lloyd Borrett
* Added ability to pass a div class wrapper, if div required
* Added ability to pass a CSS class for the img tag, if class required
* Added ability to turn off using an ancestor image
*
* 2007-03-17, 1.1 Lloyd Borrett
* Added ability to pass the image directory as an argument
*
* 2006-07-17, 1.0 Lloyd Borrett, www.borrett.id.au
Click here to download this file
#2
Posted 23 March 2007 - 02:20 AM
#3
Posted 27 March 2007 - 01:55 AM
Looks like an incredibly useful snippet, thanks Lloyd. Especially the div wrapper.
Paul
#4
Posted 04 June 2007 - 02:07 PM
The moment I thought about writing the same functionality I discovered this in the snippet library!!! Thanks a lot. Great stuff.
I have added some more functionality to the snippet :
1. Search for an image with the document-ID when the image is not found with the alias name.
2. Routine to return a random image if no image is found at all so you even can have a randomized image displayed for each document instead of those assigned by alias or ID.
See the uploaded snippet
Attached Files
#5
Posted 14 March 2008 - 07:25 PM
Minddigger, on Jun 4 2007, 10:07 AM, said:
The moment I thought about writing the same functionality I discovered this in the snippet library!!! Thanks a lot. Great stuff.
I have added some more functionality to the snippet :
1. Search for an image with the document-ID when the image is not found with the alias name.
2. Routine to return a random image if no image is found at all so you even can have a randomized image displayed for each document instead of those assigned by alias or ID.
See the uploaded snippet
Hey Minddigger - I'm unable to download your attachment, can you repost as txt format, or zipped? Thanks!
#6
Posted 13 April 2009 - 09:19 PM
I am trying to display a static image on each page of my website, and this
snippet looks like it will do the trick!
I am however, having some problems figuring out how to make it work... I am
wondering if anyone here would be so kind as to help me by explaining how to
implement it?
I have configured the image directory, which is /images/photos/ and have
put jpg as the file extension, in the config section of the file. I then added
an image in there with filename <alias>.jpg... as this is what I understood..
For example, my alias is "products-services" so I put an image file called
products-services.jpg in the /images/photos/ dir.
I am now stuck, and I am not sure how to include / call the snippet correctly
on my template page...
I have tried putting [[PageImage]] but that doesn't work... and I tried to put
[!PageImage?alias=<alias>&id=< doc id>&dir=<image directory>!]
and also <img src="[[PageImage]]"> but no luck either...
I can't figure it out
Can someone please explain to me how to call this snippet in my template?
It would be greatly appreciated!
Thank you,
Elyssa
#7
Posted 13 April 2009 - 10:25 PM
Make a new CHUNK - call it,
Quote
<img src="images/[*alias*].jpg? alt="[*alias*]">
Now, you simply match the alias of your content page with the name of your image.
I made a page here and called it with an alias of 'karen'
Then called the chunk as:
{{image-alias}}
save the file
and my image appears.
http://www.bluebonnetdesigns.com/karen.html
#8
Posted 14 April 2009 - 03:59 AM
Now, is that something you're recommending I should do, instead of using this particular
snippet? It sounds like a good solution, however I have 30 or so pages, and I don't want to
have to create 30 "chunks" - 1 for each page... I am using a template, so I want to be able to
put 1 code (snippet or chunk or whichever) which can automatically select the page photo
(alias.jpg) from a folder... this way, I can simply put 30 images in 1 folder, and have just
1 snippet...
maybe I'm not fully understanding your method lol... if it's more simple that what I
believe, I apologize...still new to all this
thanks for your help!!!
Elyssa
katherholt, on Apr 13 2009, 03:25 PM, said:
Make a new CHUNK - call it,
<img src="images/[*alias*].jpg? alt="[*alias*]">
Now, you simply match the alias of your content page with the name of your image.
I made a page here and called it with an alias of 'karen'
Then called the chunk as:
{{image-alias}}
save the file
and my image appears.
http://www.bluebonnetdesigns.com/karen.html
#9
Posted 14 April 2009 - 04:20 AM
I feel so silly! I just tried what you mentioned, and it worked!!!
it is sooo simple! I can't believe I didn't see it 10 minutes ago.
Thank you kindly for letting me know this easy solution!
Elyssa
#10
Posted 14 April 2009 - 08:30 AM
In this snippet you have the abillity to let it select a random picture instead, or let it select a picture wich has the same name as the page-id or page-alias.
I've used it a lot in (Etomite) websites and people where very pleased with this option, so here's the link
http://www.etomite.com/index.php?autocom=d...mp;showfile=297
Cheers...
#11
Posted 14 April 2009 - 01:23 PM
angelyssa, on Apr 13 2009, 10:20 PM, said:
I feel so silly! I just tried what you mentioned, and it worked!!!
it is sooo simple! I can't believe I didn't see it 10 minutes ago.
Thank you kindly for letting me know this easy solution!
Elyssa
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












