Det här tillägget har inte testats med någon av de 3 senaste huvudversionerna av WordPress. Det kanske inte längre underhålls och kan ha kompatibilitetsproblem när det används tillsammans med nyare versioner av WordPress.

Gallery From Regex Matches

Beskrivning

A plugin which adds a shortcode: [gallery_from_regex_matches] in which a regex attribute should be specified. It will then look for matches in the descriptions and titles of all published images in your library, and create a gallery from the matches it finds.

  • Använd det till exempel så här [gallery_from_regex_matches regex="lillill" exclude_ids="764"], och det kommer att generera ett galleri med alla dina bilder av ”Lillill”, förutom det som har ID 764.
  • Sometimes it might be advicable to limit the amount of matches. that can be achieved by adding limit to the shortcode. [gallery_from_regex_matches regex="lillill" exclude_ids="764" limit="10"].
  • Sometimes you want to make a gallery of ”cats” but not ”catsup”, but you don’t want to add word boundary [[:>:]], in this case you can exclude_regex=catsup. Then it could look something along the line of [gallery_from_regex_matches regex="cats" exclude_regex="catsup"].
  • Samma parametrar (med undantag för ids) som för [media] kortkoden kan användas (eftersom detta tillägg anropar den kortkodens återanropsfunktion (gallery_shortcode()) för att generera galleriet), så om du vill specificera en speciell typ (stil) av galleri av till exempel dina kattbilder, kanske detta fixar biffen: [gallery_from_regex_matches regex="/k(att|isse)/" type="square"].
  • The regular expressions follows the MySQL Regexp syntax
  • Vissa tecken kommer inte att fungera som standard i kortkoden, se sektionen ”Förbehåll”.
  • There are no bells and whistles for this plugin but it could potentionally be added in the futre.

Förbehåll

Eftersom det reguljära uttycket som används av tillägget är specificerat som ett attributvärde inuti en kortkod, och API:et för kortkoder inte tillåter vissa tecken som skulle kunna ingå i ett giltigt, användbart reguljärt uttryck, behöver man beakta några saker.

Attribute values must never contain the following characters:
* Square braces: [ ]
* Quotes: ” ’

[ … ]
The recommended method of escaping special characters in shortcode attributes is HTML encoding. Most importantly, any user input appearing in a shortcode attribute must be escaped or stripped of special characters.

  • if in the regex you need to macth a character set [a-z], then (following the shortcode Api documentation guidline), they need to be encoded. There are two encodings which the plugin accepts: ”html” and ”base64”
  • Just nu finns det inget sätt att koda dessa saker med hjälp av tillägget, men det är planerat för en framtida version. Tills vidare behöver man koda de reguljära uttrycken manuellt.
    Till exempel kan det reguljära uttrycket /w[0u][0u]t/i uttryckas på något av följande vis:

Med HTML-kodning:
[gallery_from_regex_matches regex="/w[0u][0u]t/i" encoding="html"]

Med Base64-kodning:
[gallery_from_regex_matches regex="L3dbMHVdWzB1XXQvaQ==" encoding="base64"]

To encode a string to base64, it can be done from the terminal like this:
% echo -n "catsup" | base64
Y2F0c3Vw
% echo -n Y2F0c3Vw | base64 --decode
catsup%

Installation

  1. extrahera zip-filen till katalogen /wp-content/plugins
  2. Aktivera tillägget via menyn ”Tillägg” i WordPress.

Recensioner

5 februari 2018
We needed to group the pictures in our gallery in a way that wasn't obvious but this plugin flexibility got the job done! Totally recommended.
Läs 1 betyg

Bidragsgivare och utvecklare

”Gallery From Regex Matches” är programvara med öppen källkod. Följande personer har bidragit till detta tillägg.

Bidragande personer

”Gallery From Regex Matches” har översatts till 1 språk. Tack till översättarna för deras bidrag.

Översätt ”Gallery From Regex Matches” till ditt språk.

Intresserad av programutveckling?

Läs programkoden, kika på SVN-filförvaret eller prenumerera på utvecklarloggen via RSS.

Ändringslogg

0.6.3

  • Fixed a bug in which attachments with no parent were never selected.

0.6.2

  • Fixed a bug with mysql query and empty regexp

0.6.1

  • Added exclude_regex shortcode parameter.

0.6.0

  • Move the regex matching into the database and use MySQL regex syntax instead of calling all posts and applying the regex filters on them. This to increase performance and to work better on big galleries.
  • Syntax for regex attr then is also slightly changed: no need to use delimiter ’/’: ”/(cat|kitten)/” is now written ”(cat|kitten)”, but either way will work for backwards-compatiblity reasons.
  • Number of matches can now be limited with the limit which defaults to 10000, but can be set to a higher value if need be.

0.5.1

  • Lägg till möjlighet att avkoda kodade reguljära uttryck, så att specialtecken som kan tänkas kollidera med API:et för kortkoder fortfarande kan användas.

0.5

  • Sök även rubrikfält
  • use preg_grep on array of target search fields instead of concatinating it to a string as that can lead to unforseen matches.

0.1

Första prov-version. Kan innehålla programfel.