1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-11 07:34:22 +02:00

feat(shortcodes): add new shortcode - media_files_fetch

example:

[media_files_fetch id="foo.txt" field="title" default="Bar"]
This commit is contained in:
Awilum
2021-01-13 14:12:35 +03:00
parent 86a42ee2c3
commit 5096c0d513
3 changed files with 42 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
<?php
declare(strict_types=1);
/**
* Flextype (https://flextype.org)
* Founded by Sergey Romanenko and maintained by Flextype Community.
*/
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
// Shortcode: [media_files_fetch id="media-id" field="field-name" default="default-value"]
if (flextype('registry')->get('flextype.settings.parsers.shortcode.shortcodes.media.enabled')) {
flextype('parsers')->shortcode()->addHandler('media_files_fetch', static function (ShortcodeInterface $s) {
return arrays(flextype('media')->files()->fetch($s->getParameter('id')))->get($s->getParameter('field'), $s->getParameter('default'));
});
}

View File

@@ -354,6 +354,8 @@ parsers:
max_nesting_level: INF
shortcode:
shortcodes:
media:
enabled: true
entries:
enabled: true
raw: