This question is not answered. Helpful answers available: 1. Correct answers available: 1.


Permlink Replies: 6 - Pages: 1 - Last Post: 23 Jun 08, 22:38 Last Post By: davidekholm Threads: [ Previous | Next ]
John Simpson

Posts: 2
Registered: 11-Jul-2007
Using Image TITLE in your Skins
Posted: 22 Jun 08, 19:02
 
  Click to reply to this thread Reply
Here is some code for inserting the TITLE of an image from the new JA8 INPUT field on the GUI.

The following code puts a TiTle on the Slide page.

Ideally this should be placed above the image in SLIDE.HTT

<!-- If exists display JAlbum GUI Slide Title otherwise display title extracted from photo IPTC data -->
 
<h3>
<ja:if exists="fileTitle">${fileTitle}</ja:if>
<ja:else>
  <ja:if exists="meta"><%= meta.get("Iptc.Object Name") %></ja:if>
</ja:else>
</h3>


My thanks to Heinz-Peter for help with the script.

Also you can use the IMAGE TITLE in the HEAD section of SLIDE.HTT as follows:


<!-- use GUI slide file title or photo name for meta description -->
<meta name="description" content="<ja:if exists="fileTitle">${fileTitle}</ja:if><ja:else>$label</ja:else>">
 
<!-- use GUI slide file title or photo name for page title  -->
<title><ja:if exists="fileTitle">${fileTitle}</ja:if><ja:else>$label</ja:else></title>
 


And in image source so that the image title displays as the alt text and title tool tip text for a displayed image.
<img src="$imagePath" width="$imageWidth" height="$imageHeight" title= "<ja:if exists="fileTitle">${fileTitle}</ja:if><ja:else>$label</ja:else>"alt= "<ja:if exists="fileTitle">${fileTitle}</ja:if><ja:else>$label</ja:else>">
 


changed from this:

<!-- <img src="$imagePath" width="$imageWidth" height="$imageHeight" alt="$label"> -->


Edited by: John Simpson on 22-Jun-2008 18:31
JeffTucker

Posts: 8,098
Registered: 31-Jan-2006
Re: Using Image TITLE in your Skins
Posted: 22 Jun 08, 21:13   in response to: John Simpson in response to: John Simpson
Helpful
  Click to reply to this thread Reply
This "fix" is not applicable to all skins. For some skins (like the Flash skins), this won't work at all. For others, inserting things at odd places will "break" the layout.
JeffTucker

Posts: 8,098
Registered: 31-Jan-2006
Re: Using Image TITLE in your Skins
Posted: 22 Jun 08, 21:25   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
Rather than testing for the existence of fileTitle, it's probably better to check whether it's blank or not:

<ja:if test="${fileTitle}" not value="">${fileTitle}</ja:if><ja:else> (something else) </ja:else>

This ensures that you're looking at the fileTitle variable for the current image (a scope issue), and prevents you from grabbing a blank (the variable exists, but is empty).
davidekholm

Posts: 3,711
Registered: 18-Oct-2002
Re: Using Image TITLE in your Skins
Posted: 22 Jun 08, 21:30   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
The ja:if exists="variable name here" construct also requires the variable to be not empty.
John Simpson

Posts: 2
Registered: 11-Jul-2007
Re: Using Image TITLE in your Skins
Posted: 23 Jun 08, 10:49   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
In reply to all above.

The skin that I use is based upon the JAlbum STANDARD skin - I should have mentioned that.

Secondly the solution works fine for me.

For the first code example where I generate a TITLE to be placed above the IMAGE in SLIDE pages.

If there is no GUI TITLE and no TITLE in IPTC PHOTO DATA then it just returns a blank - which is what I want.

Are you saying that although it works (for me) - that it is bad coding practice?

In the other examples of code the IF statement returns the file name of the photo ($label) which always exists. I presume that this coding logic is okay?

David, maybe you should give examples of how this new IMAGE TITLE field should be applied to your STANDARD SKIN.

My requirements are for IMAGE TITLE are:

SLIDE.HTT

1. Displays as header above image if exists OR display IPTC data TITLE if not - otherwise display nothing.

2. used in IMAGE ALT tag - otherwise image file name.

3. Used in IMAGE TITLE tag - otherwise image file name.

4. Used in HEAD tag of a web page - otherwise image file name.

5 Used in the META DESCRIPTION - otherwise image file name.

INDEX.HTT

1. used in IMAGE ALT tag - otherwise image file name.

2. Used in IMAGE TITLE tag - otherwise image file name.

See what a useful INPUT field you created - and this will go someway to creating a proper web site.

Edited by: John Simpson on 23-Jun-2008 09:50
JeffTucker

Posts: 8,098
Registered: 31-Jan-2006
Re: Using Image TITLE in your Skins
Posted: 23 Jun 08, 15:05   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
davidekholm wrote:
The ja:if exists="variable name here" construct also requires the variable to be not empty.

Yes, for fileTitle that should work fine. But I seem to remember running into a scope problem when checking for a folder title. Does the "exists" syntax allow something like:

<ja:if exists="local.folderTitle">

or

<ja:if exists="{folderTitle}">
davidekholm

Posts: 3,711
Registered: 18-Oct-2002
Re: Using Image TITLE in your Skins
Posted: 23 Jun 08, 22:37   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
Sorry, no it doesn't, so that needs to be tested like this:
<ja:if not test="${local.folderTitle}" value="">...</ja:if>
Legend
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums