plugin-icon

Gallery From Regex Matches

Av doddo·
Maintain a gallery by including all published images in your library which match a regex (in title or description).
Betyg
5/5
Version
0.6.3
Senast uppdaterat
May 30, 2019
Gallery From Regex Matches

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%

Gratispå Business-paket
Testat upp till
WordPress 5.2.23
Detta tillägg är tillgängligt för nedladdning för din .