Do we have smarty variables for the alt & title attributes entered into the media library.
For instance, I have an extended property field that contains a path to a document: {$entry.properties.ep_document}
The value of that is likely to be /uploads/myfolder/whatever.pdf. Now, I really do not want to display that as <a href="/uploads/myfolder/whatever.pdf">/uploads/myfolder/whatever.pdf</a>
I would rather emit it as <a href="/uploads/myfolder/whatever.pdf">Nice Title</a>, where "Nice Title" is the media library value for "title" (s9y v1.5+)...
So can we do something like:
<a href="{$entry.properties.ep_document}">{$media.title['entry.properties.ep_document']}</a> ???
I made up that media title bit, but hopefully you code junkies know what I mean by it...
ALT & title for path entered into extended properties
-
- Regular
- Posts: 3652
- Joined: Mon Feb 13, 2006 2:40 am
- Location: Chicago, IL, USA
- Contact:
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: ALT & title for path entered into extended properties
Hi!
No, the media properties are not read. This would be a quite costy DB lookup, so it's not done by default.
You would need to utilize the s9y API functions (in include/functions_images.inc.php) to fetch a meida item - you could wrap that inside a custom smarty function in your template's config.inc.php.
For example, the API function to fetch image properties is serendipity_fetchMediaProperties() and serendipity_prepareMedia(). They both however require an ID to the document instead of the name. So you would first need to check the serendipity_images database for the ID to your name (or you immediately store the ID instead of the filename in your entryproperty).
Then in your config.inc.php you could do something like (PSEUDOCODE!):
and then in your template:
Next step would be to add caching to the custom modifier, so that it does not lookup the same image more than once...
That involves a lot of coding, as you might see
Best regards,
Garvin
No, the media properties are not read. This would be a quite costy DB lookup, so it's not done by default.
You would need to utilize the s9y API functions (in include/functions_images.inc.php) to fetch a meida item - you could wrap that inside a custom smarty function in your template's config.inc.php.
For example, the API function to fetch image properties is serendipity_fetchMediaProperties() and serendipity_prepareMedia(). They both however require an ID to the document instead of the name. So you would first need to check the serendipity_images database for the ID to your name (or you immediately store the ID instead of the filename in your entryproperty).
Then in your config.inc.php you could do something like (PSEUDOCODE!):
Code: Select all
function showimage($filename, $i_want = 'description') {
$id = serendipity_db_query("SELECT ... FROM images WHERE bla LIKE '%filename%'");
$media = serendipity_fetchMediaProperties($id);
serendipity_prepareMedia($media);
return $media[$i_want];
}
$serendipity['smarty']->register_modifier('showimage', 'showimage');
Code: Select all
<a href="{$entry.properties.ep_pic}" alt="{$entry.properties.ep_pic|@showimage:'description'}">...</a>
That involves a lot of coding, as you might see
Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Re: ALT & title for path entered into extended properties
If I understand Don correctly, the easier way is to simply add entry properties for alt and title. Note that it is pointless to add both alt and title if they're the same. (Yes, I know, IE[< 6] doesn't display alt as a title or something -- screw it.)garvinhicking wrote:That involves a lot of coding, as you might see
YL
-
- Regular
- Posts: 3652
- Joined: Mon Feb 13, 2006 2:40 am
- Location: Chicago, IL, USA
- Contact:
Re: ALT & title for path entered into extended properties
Thanks Garvin - that is indeed brutal, and has me wondering why we even have media properties such as ALT and title if they are so difficult to fetch. Is all this difficulty happening when inserting an image into an entry???
Yellowled - yes, extended properties is an easy way to do it, but I wanted a single place to provide this information. Imagine a document is inserted into 6 different entries ... the author would have to provide a title for the document 6 times. If the author could just provide this title when he first uploaded the media item, that would a) save time and b) lead to consistency in the title.
And yes, I could use a single property for both alt and title text. In my example, it is for a document, which would not need alt text anyway.
Yellowled - yes, extended properties is an easy way to do it, but I wanted a single place to provide this information. Imagine a document is inserted into 6 different entries ... the author would have to provide a title for the document 6 times. If the author could just provide this title when he first uploaded the media item, that would a) save time and b) lead to consistency in the title.
And yes, I could use a single property for both alt and title text. In my example, it is for a document, which would not need alt text anyway.
=Don=
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: ALT & title for path entered into extended properties
Yes. The admin imageselector and frontend details all fetch this; also when you use serendipity_Adminm_imageselector.php?id=... to link to a picture on the fullscreen to display metadata. But embedding it in entryproperties field is simply something that is not integrated from the core yet.Don Chambers wrote:Thanks Garvin - that is indeed brutal, and has me wondering why we even have media properties such as ALT and title if they are so difficult to fetch. Is all this difficulty happening when inserting an image into an entry???
The Smarty-Interface to the MDB has been sponsored by a customer of our company and was an awful lot of work. For him, the blog part of s9y was not important, which is why no funding landed there.
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
-
- Regular
- Posts: 3652
- Joined: Mon Feb 13, 2006 2:40 am
- Location: Chicago, IL, USA
- Contact:
Re: ALT & title for path entered into extended properties
Just so there is no misunderstanding, I already have what I want in an extended property field, which is the path to a document in the media library.
What I want is to use the "title" attribute from the media library for this document as <a href="path">title</a> emitted by a smarty template - specifically, entries.tpl.
What I want is to use the "title" attribute from the media library for this document as <a href="path">title</a> emitted by a smarty template - specifically, entries.tpl.
=Don=
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: ALT & title for path entered into extended properties
Hi Don!
No misunderstanding here - my description fits your needs.
Regards,
Garvin
No misunderstanding here - my description fits your needs.
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/