Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2018-11-13 13:41:02

Vienuolis
Member
From: Vilnius, Lithuania
Registered: 2009-06-14
Posts: 172
Website

txp:thumbnail of author's portrait

I would like to add authors’ portraits to their names in a corresponding article context, as seen on on.lt/tiesa.

I have added the category “autoriai” (authors) and assigned to it single photos of each author, named by their login name.jpg. Also checked an authorship of them in the image panel.

<txp:image name='<txp:author title="0" />' />

An empty output. Inside of the txp:article. Weird. Why?

Tag error: <txp:image name=’<txp:author title=“0” />’ /> -> Textpattern Notice: Unknown image while parsing form pranesimas on page pamokos
textpattern/lib/txplib_misc.php:975 trigger_error()
textpattern/publish/taghandlers.php:329 imageFetchInfo()
image()
textpattern/vendors/Textpattern/Tag/Registry.php:116 call_user_func()
textpattern/lib/txplib_publish.php:547 Textpattern\Tag\Registry->process()
textpattern/lib/txplib_publish.php:471 processTags()
textpattern/lib/txplib_misc.php:4364 parse()
textpattern/publish.php:938 parse_form()
textpattern/publish.php:971 doArticle()
textpattern/publish.php:732 parseArticles()

Trying a bit differently:

<txp:images name='<txp:author title="0" />' /> , else
<txp:images name='<txp:author title="0" />'><txp:thumbnail /></txp:images>

The same output — null.

<txp:images category="autoriai" author='<txp:author title="0" />' />

The portrait is shown as expected now. Linked to a nonsense URL, though:

https://on.lt/pamokos/?c=autoriai&context=image&p=57

Finally I have got a correct output by the following TxP code:

<txp:images category="autoriai" author='<txp:author title="0" />' auto_detect="" limit="1"><txp:thumbnail /></txp:images>

The limit and auto_detect are optional attributes here, although possibly they would be useful to avoid unnecessary SQL queries sometimes. Am I on the right way, is this code optimal?

Last edited by Vienuolis (2018-11-13 13:50:10)

Offline

#2 2018-11-13 13:54:26

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,458
Website

Re: txp:thumbnail of author's portrait

I’m surprised your last example works. That asks Txp to find images in the autoriai category that have been uploaded by the given author (login) name. It probably works for you, but nobody else!

Your first example matches the ‘Image name’ field. So if you edit each image and give it a name (without extension) that exactly matches the corresponding login name then you should be able to pull the individual image out without going through <txp:images>.

Last edited by Bloke (2018-11-13 13:55:34)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#3 2018-11-13 14:07:55

Vienuolis
Member
From: Vilnius, Lithuania
Registered: 2009-06-14
Posts: 172
Website

Re: txp:thumbnail of author's portrait

Bloke wrote #315203:

uploaded by the given author (login) name. It probably works for you, but nobody else!

Textpattern lets to rename and reassign an authorship of images in the images panel. Verified by others, you ca look to another webpages yourself, too.

Offline

#4 2018-11-13 14:14:03

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,458
Website

Re: txp:thumbnail of author's portrait

Vienuolis wrote #315206:

Textpattern lets to rename and reassign an authorship of images in the images panel.

True. If you have logins for each contributor, then your final approach works and is the most efficient way.

The <txp:image> tag can’t pull images by author because it might result in more than one image in the result. The images tag does allow it as it’s designed for galleries. The fact you have a gallery of one image is immaterial.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#5 2018-11-13 14:28:15

Vienuolis
Member
From: Vilnius, Lithuania
Registered: 2009-06-14
Posts: 172
Website

Re: txp:thumbnail of author's portrait

If you have logins for each contributor

I have publisher rights there. In general, it is sufficient to ask the publisher to correct once if something went wrong. Or remove and upload, rename own photo again.

Offline

#6 2018-11-13 17:01:14

Vienuolis
Member
From: Vilnius, Lithuania
Registered: 2009-06-14
Posts: 172
Website

Re: txp:thumbnail of author's portrait

Found my mistake, sorry for disturbance. <txp:image name="filename.jpg" />, not “filename” with no extension. The valid TxP code for this task is quite simple:

<txp:thumbnail name='<txp:author title="0" />.jpg' />

Last edited by Vienuolis (2018-11-14 11:31:36)

Offline

#7 2018-11-14 11:24:14

Vienuolis
Member
From: Vilnius, Lithuania
Registered: 2009-06-14
Posts: 172
Website

Re: txp:thumbnail of author's portrait

If both snippets (by filename or category) are correct, they might fit to the tag reference as typical implementation examples. I am wondering why this feature is absent in the core of Textpattern. I am always willing to see a human face of the reporter, at least his avatar, while I am reading him.

Offline

Board footer

Powered by FluxBB