Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-11-28 15:24:41

trenc
Plugin Author
From: ⛵️, currently Göteborg, SE
Registered: 2008-02-27
Posts: 574
Website GitHub

yab_image (display floating image+caption/subtitles)

Yes, another image plugin for textpattern. :)

The problem and the solution

Because raw html is not allowed in this forum have a look at the plugin site. It will show some examples of the problem.

What it does

This plugin allows you to display an image with an assigned caption as caption :). The width of the caption will always fits the width of the displayed image.

Usage

You can use this plugin almost the same as <txp:image />. The behavior is a little bit different: If a caption for an image is available and if you want to float the image and the caption, use the align attribute. This will float the image and the caption.

If no image caption (neither as tag attribute nor in image tab) is given <txp:yab_image /> works similar as <txp:image />·

F.i.: <txp:yab_image id="5" align="right" />

Attributes

The following attributes works as expected (as in <txp:image />·) when no caption is given:

id
Specifies the id assigned at upload of the image to display. Can be found on the images tab. If both name and id are specified, name is used while id is ignored.
(Integer)
name
Specifies which image to display by its image name as shown on the images tab.
(String)
class
CSS class attribute applied to the wraptag, if set, otherwise to the img tag.
(Default: unset)
escape
Escape HTML entities such as <, > and & for the image’s alt and title attributes.
(Default: unset)
html_id
The HTML id attribute applied to the wraptag, if set, otherwise to the img tag.
(Default: unset)
style
Inline CSS style rule.
(Default: unset)
wraptag
HTML tag to be used to wrap the img tag, specified without brackets.
(Default: unset)

The following attributes are new oder modified:

align
Alignment of the image and the caption.
left, right, center (default: center)
alt_caption
Alternate caption, overwrites caption given in image tab.
(Default: unset)
alt_alt
Alternate img alt, overwrites alternate text given in image tab.
(Default: unset)
alt_title
Alternate title, overwrites caption text given in image tab, which is regulary used for img title attribute.
(Default: unset)
alt_as_title
If set, the alt_alt tag attribute or the alternate text is used for the img title attribute.
(Default: 0)

Some weird logic and priorities:

Tag attributes will always overwrites given text in the image tab!

Intentionally usage of alt_as_title tag attribute:
Mainly it could be used for displaying hyperlinks in the caption (the thingy, which is shown under the image) without breaking the HTML validity.
If you want to display hyperlinks in the caption so you can either write these hyperlinks as raw HTML in the caption field in your image tab or as textile markup in the tag attribute:

F.i.: <txp:yab_image id="5" align="right" alt_caption='This is a "Link (Link)":http://textpattern.com/ in a caption' />

Important:
  • Use single quotes for tags when insert double quotes!
  • Don’t start with an double quote (alt_caption='"Link (Link)":http://textpattern.com/ in a caption' will not work).
    Use a beginning whitespace or text before the double quote (alt_caption=' "Link (Link)":http://textpattern.com/ in a caption').
  • Be sure the line will be textiled.

Problem: The generated img title attribute is broken, because the hyperlink with the double quotes breaks it.
Solution: Now you can additionally use the alt_title tag attribute to set a specific img title or the alt_as_title so that the img title will generated from alternate text in the image tab.

F.i.: <txp:yab_image id="5" align="right" alt_caption='This is a "Link (Link)":http://textpattern.com/ in a caption' alt_as_title="1" />

or

F.i.: <txp:yab_image id="5" align="right" alt_caption='This is a "Link (Link)":http://textpattern.com/ in a caption' alt_title="Nice picture which shows something" />

Styling

The plugin will create new html elements:

If an image caption is given:
<small class="caption">given caption here</small>: This elements will wrap the caption.

And if additionally the attribute align is used:
<span class="img-caption-{align}">image+caption</span>, where {align} will be your given align: This span is wrapped around the image and the caption. So you have the ability to set different paddings for different floats.

You can always use the wraptag attribute to wrap all with another html element.
Depending on your usage and used wraptag you have to clear the floats.

As of version 0.3 <txp:yab_image /> will produce (X)HTML-strict output. The align attribute in the image element will be completly removed. So the HTML-markup will be different from <txp:image />.

Download

yab_image_v0.5 plugin
yab_image v0.5 source

Changelog

  • 08-11-28 – v0.1
    • release
  • 08-11-30 – v0.2
    • added: alt_caption attribute for alternative captions
  • 09-04-08 – v0.3
    • removed image align attribute in html markup, so output will be (X)HMTL-strict
    • added different css classes for different floats for styling purpose
  • 10-09-24 – v0.4
    • can now handle hyperlinks in captions
    • added: alt_alt attribute for alternative img alt attribute
    • added: alt_title attribute for alternative img title attribute
    • added: alt_as_title attribute for alternative img title attribute
  • 2017-02-10 – v0.5
    • TXP 4.6-ready

Last edited by trenc (2017-02-10 15:16:14)


Digital nomad, sailing the world on a sailboat: 32fthome.com

Offline

#2 2008-11-28 16:14:00

lee
Member
From: Normandy, France
Registered: 2004-06-17
Posts: 831

Re: yab_image (display floating image+caption/subtitles)

Soooooo useful. Thanks.

Offline

#3 2008-11-30 11:49:59

trenc
Plugin Author
From: ⛵️, currently Göteborg, SE
Registered: 2008-02-27
Posts: 574
Website GitHub

Re: yab_image (display floating image+caption/subtitles)

I’ve added a new attribute: alt_caption="This is a alternative caption", so you can use an image more than once with different captions.


Digital nomad, sailing the world on a sailboat: 32fthome.com

Offline

#4 2008-11-30 14:17:55

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

Re: yab_image (display floating image+caption/subtitles)

This is a real time saver! Ausgezeichnet!

Offline

#5 2008-12-06 01:49:08

macinchik
Member
Registered: 2007-02-08
Posts: 17

Re: yab_image (display floating image+caption/subtitles)

Can this plug-in be used with the article image tag?

Offline

#6 2008-12-06 11:07:52

Niconemo
Member
From: Rhône-Alpes, France
Registered: 2005-04-18
Posts: 557

Re: yab_image (display floating image+caption/subtitles)

Thank you. One more nice plugin :-)

;-) But, for those who use upm_image (and upm_img_popper) you can do that this way for a long time in the Custom form (it’s an example)…

<div class="img-with-caption" style="width <txp:upm_img_full_width />px" > <img src="<txp:upm_img_full_url />" alt="<txp:upm_img_alt />" /> <br /><span class="img-caption"> <txp:upm_img_caption /></span> </div>

Last edited by Niconemo (2008-12-06 11:12:42)


Nico

Offline

#7 2008-12-06 12:10:08

trenc
Plugin Author
From: ⛵️, currently Göteborg, SE
Registered: 2008-02-27
Posts: 574
Website GitHub

Re: yab_image (display floating image+caption/subtitles)

macinchik wrote:

Can this plug-in be used with the article image tag?

No, you can’t used it as replacement or with the <txp:article_image />-tag, but if you want maybe you can use upm_image as Niconemo described or with the <txp:upm_article_image />, but I can’t say it exactly — haven’t used upm_image yet. But I think, it should works in some way.

<txp:yab_image /> is intended to be used in the article body or excerpt. For forms and pages there are many, many different others image plugings that will do the job for you.


Digital nomad, sailing the world on a sailboat: 32fthome.com

Offline

#8 2008-12-08 18:30:11

macinchik
Member
Registered: 2007-02-08
Posts: 17

Re: yab_image (display floating image+caption/subtitles)

Got it. Thanks!

Offline

#9 2009-04-08 09:24:04

trenc
Plugin Author
From: ⛵️, currently Göteborg, SE
Registered: 2008-02-27
Posts: 574
Website GitHub

Re: yab_image (display floating image+caption/subtitles)

I’ve released a new version.

Now the output is (X)HTML-strict. This way I have removed the align-attribute in the html img element.
Further the wrapped span class has changed. Now it will depend on the given align attribute:

<span class="img-caption-left">image+caption</span>
or
<span class="img-caption-right">image+caption</span>
or
<span class="img-caption-center">image+caption</span>

So you have the ability to set different paddings.


Digital nomad, sailing the world on a sailboat: 32fthome.com

Offline

#10 2009-04-11 00:57:11

floodfish
Member
From: Brooklyn, NY
Registered: 2007-01-11
Posts: 155
Website

Re: yab_image (display floating image+caption/subtitles)

Can this be made to work with the default article image rather than inserting the image id in the tag?

Offline

#11 2009-04-11 08:28:33

trenc
Plugin Author
From: ⛵️, currently Göteborg, SE
Registered: 2008-02-27
Posts: 574
Website GitHub

Re: yab_image (display floating image+caption/subtitles)

Hi Jason,

Can this be made to work with the default article image rather than inserting the image id in the tag?

There is no need for. You can do this with upm_image as Niconemo described above.


Digital nomad, sailing the world on a sailboat: 32fthome.com

Offline

#12 2009-04-11 19:23:58

floodfish
Member
From: Brooklyn, NY
Registered: 2007-01-11
Posts: 155
Website

Re: yab_image (display floating image+caption/subtitles)

Oh, duh. Thank you!! Somehow I missed half of this thread!

Offline

Board footer

Powered by FluxBB