yab_image: another image plugin for textpattern

Yes, another image plugin for textpattern. :)

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.

The problem

In textpattern you have an option to give an uploaded image a caption, but textpattern will show this caption via textile, tag <txp:image /> or html only as title attribute of the image element. This is not a real image-caption aka image-subtitle.

If you want a real image-caption in textpattern so you have to work with different <span> in your body with textile or with raw html. The next problems are the different widths of the images and the caption (subtitle) below.

Here is an example what I mean:


Example Picture 1 This is a caption with an appropriate width Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem.

Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim.

Example Picture 1 This is a longer caption and the width could break your layout Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem.

Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim.


Solution

If you know this problem and you often use or want to use image-captions then maybe yab_image is a solution for you. The example above will with <txp:yab_image /> look like this:

Example Picture 2This is a longer caption of the image. With yab_image the caption doesn't break your layout.Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem.

Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim.

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

yab_download: Tiny textpattern plugin to offer downloads

I wrote a tiny textpattern plugin for a customer of mine. It’s nothing spectacular, but if someone need it, feel free to download.

What it does

This plugin allows you to offer a download of multiple files (per file id and/or category) with or without a confirmation button. Additionally you can offer an option to download all the files as zip archive on the fly. The names of the files are read from the files description. If no description is given the filenames are displayed.

Usage

This plugin has only one tag: <txp:yab_download />. You have to place it in an individual article.
The following attributes are available:

  • files: The IDs of the files, which are for download (seperated by comma). If no files assigned with an ID an error message will displayed in the option field.
  • label1: Label for select
  • label2: Label for confirmation checkbox
  • label3: Label for the submit input
  • label4: Label for zip download checkbox
  • notice: Error notice, if confirmation is not set but required
  • size: Display filesize additionally (values are B, KB,MB, GB,PB).
  • confirm : Form used with a confirmation checkbox (values: ‚1‘ or some other string)
  • formid: html id of the element form, used for anchor, if you use more than one <txp:yab_download /> in a single site, make different entries here; (default yab_cd_download)
  • cats: File categories you will add to download (seperated by comma); will additional displayed with files from files attribute above
  • exclude: IDs of the files you will exclude; Does only work with cats attribute.
  • sort: Sort the files from cats; (defaul description asc)
  • zip: Offfers an checkbox with an option to download all offered files as zip instead (values: ‚1‘ for zip creation; ‚2‘ to force zip creation in memory)
  • zipname: the name of the offered zip (default all.zip)
  • hidelist: hides the select list of the files, usefull if you offer only one file or offer many files zipped without a seletion (values: ‚1‘)
  • hidezip: hides the zip checkbox (download as zip is forced), useful if you offer only one file as zip or many files as zip wihtout a file selection; can be combined with ‚hidelist‘, so only a download button will be displayed (values: ‚1‘)

Example usage

simple
<txp:yab_download files="1,2,3,4" />

full
<txp:yab_download files="1,2,3,4" label1="Choose your download" label2="Accept Download at your own risk" label3="Klick here for download" label4="Yeah give me all as zip" notice="You have to accept the condition below" size="MB" formid="form-no-1" confirm="1" cats="category1, category2" exclude="5,7" sort="filename desc" zip="1" zipname="archive.zip" />

The full example above will show you a form with two checkboxes. First one offers an option to download all the files zipped. The second checkbox is a confirmation checkbox.
The offered files will be the files with the file id #1, #2, #3, #4 and all files of the categories category1 and category2. If in category1 or category2 a file with the file id #5 and #7 so these will be excluded from download. The zipped file will be named as archive.zip.

Note on zip creation

If you are running a php version 5.2.0 or above so the attribute zip="1" will try to create the zip on harddisk instead in memory. If you have php 5.2.0 or above and you have problems with some restrictions like safe_mode, open_basedir etc., so try the attribute zip="2". This will force the zip creation in memory.

Download

This download of the plugin shows you a real world example.

If you have yab_confirmed_download v0.1 installed, disable or remove it, please! The plugin has been renamed.

Changelog

  • 08-11-23 – v0.1
    • release
  • 08-11-27 – v0.2
    • renamed the plugin to yab_download
    • added: confirmation is now optional
    • added: support files per categories
    • added: sort per category
    • added: files exclude
    • added: zip-on-the-fly
    • added: attribute formid for unique html ids for multiple plugin usage per page
  • 08-12-01 – v0.3
    • bugfix: filesize of category listing will now correctly calculated
    • bugfix: minor code improvement
  • 08-12-21 – v0.4
    • bugfix: code improvement (see comment below, thanks Geoffrey)
  • 09-01-08 – v0.5
    • bugfix: code improvement (see comment below, thanks Geoffrey); if a php 5.2.0 is running so zip creation will be on harddisk instead in memory
  • 09-11-16 – v0.6
    • bugfix: filenames and filedescriptions are now correctly escaped
    • added: new attribute ‚hidelist‘ hides the file selection list
    • added: new attribute ‚hidezip‘ hides the download-as-zip checkbox
  • 2017-02-10 – v0.7
    • TXP 4.6-ready

wow-wotlk-allyretrpala

Der Titel ist ein Brüller, oder?
Ich glaub, nächsten Donnerstag und Freitag mach ich nix: WOTLK-Release!

Btw: Allianzvergelterpala ist ‘ne super Beleidigung — find’ ich — wenn sie es denn verstünden.

Ghostbusters III

Obwohl die Aufklärungsquote bei Morden in der Regel bei ca. 90% (in der DDR natürlich 100%) liegt, also wahrscheinlich viel höher, als allgemein angenommen, bleibt ein kleiner Rest von Tätern, die sich einer gerechten Strafe entziehen. Aber dies könnte daran liegen, dass es sich hierbei um Verbrechen handelt, die mithilfe von Methoden ausgeführt worden, denen die normale Kriminalistik nichts entgegenzusetzen hat. Aber Hilfe naht, denn jüngere Juristen werden inzwischen entsprechend geschult und können ihr spezielles Wissen auch sehr schnell an die nächste Generation weitergeben. Als ein Beispiel unter hoffentlich vielen sei Tonio Walter genannt, Professor für Strafrecht an der Uni Regensburg. Neben der üblichen Paragraphenpaukerei belegte er während seines Studiums als Nebenfach “Seriöse Parapsychologie” und ist somit in der Lage, billige Alibis zu durchschauen, die von in der realen Welt operierenden Strafverfolgungsbehörden tatasächlich ernst genommen worden wären.

Denn auch wenn der Verdächtigte zur Tatzeit Hunderte Kilometer vom Opfer entfernt in der Kneipe saß und 10 Zeugen dies bestätigen können, heißt das noch lange nicht, dass er nicht nebenbei (“muss nur mal schnell auf´s Klo”) per Telekinese mehrfach mit dem Messer auf die nervige Schwiegermutter eingestochen hat. Schließlich gilt, was Prof. Walter in der Rezension des Buches “Willensfreiheit und rechtliche Schuld” von Reinhard Merkel, in dem es um die neuesten Hypothesen aus der Hirnforschung und ihre Auswirkungen auf das Strafrecht bzw. die persönliche Schuld geht, schreibt:

Wie sich im Geistigen ein Wille formt, kann die Naturwissenschaft nicht ergründen. Ebensowenig kann sie die Grenzen des Weltalls abstecken. Beweist das, dass es diese Grenzen nicht gibt? Und der Hinweis, es existiere kein einziger Beleg, dass immaterieller Geist auf Materie einwirken könne, wischt alle Religionen ebenso beiseite wie die seriöse Parapsychologie, die durchaus schon telekinetische Phänomene unter Laborbedingungen dokumentiert hat.

Um Mitglied der juristischen Spezialeinheit zu werden, muss man also nur voraussetzen, dass Religionen nicht grundsätzlich falsch liegen können und zweitens den tatsächlichen Forschungsstand bezüglich Telekinese ignorieren, beides dürfte nicht so schwer sein. Obwohl böse Zungen behaupten, das beste Argument gegen die Existenz von Telekinese sei immer noch die Fernbedienung…

Das hat man nun davon

Eigentlich hatte ich Anfang Juni nur Gutes im Sinn: Die Millionen zählende Leserschar dieses Blogs auf hervorragende Musik aufmerksam machen. Aber nur 3 Monate nachdem ich die beiden letzten CDs von Sieges Even empfohlen habe, lösen sie sich einfach auf (Yoko Ono?).
Aber ich möchte in diesem wirklich bedauerlichen Ereignis dann wenigstens einen geheimen Mechanismus erkennen und folgende Hinweise weitergeben:

  • die NPD ist eine tolle Partei, sie sollte ab jetzt immer gewählt werden
  • Mario Barth ist total lustig und bald noch viel häufiger im TV zu sehen
  • Jimi Blue ist ein genialer Rapper mit absoluter street-credibility und langfristigem Plattenvertrag

Und jetzt muss ich nur noch in aller Seelenruhe zuschauen, wie das Universum seine Arbeit verrichtet…

Famous last words

Oder: manchmal genügt die Lektüre des letzten Satzes einer Pressemitteilung, um selbige einzuordnen. Yablo proudly presents die dümmste Bemerkung der Woche:

Schätzungen zufolge werden alleine mit dem beliebten wie aufgrund seiner Brutalität berüchtigten Marktführer „World of Warcraft“ jährlich rund eine Milliarde Dollar Umsatz erzielt.

Und jetzt lassen wir die bayerischen Philologen zur Strafe zehnmal “völlig arglos und unbedarft” an die Tafel schreiben.

neuere Einträge | ältere Einträge