-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #585 from getformwork/feature/file-meta
Add support for files metadata
- Loading branch information
Showing
25 changed files
with
386 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,7 @@ fields: | |
|
||
files: | ||
allowedExtensions: [] | ||
metadataExtension: .meta.yaml | ||
|
||
images: | ||
jpegQuality: 85 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Formwork\Model\Attributes; | ||
|
||
use Attribute; | ||
|
||
#[Attribute(Attribute::TARGET_PROPERTY)] | ||
class ReadonlyModelProperty | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
formwork/src/Parsers/Extensions/CommonMark/ImageAltProcessor.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace Formwork\Parsers\Extensions\CommonMark; | ||
|
||
use Formwork\App; | ||
use League\CommonMark\Event\DocumentParsedEvent; | ||
use League\CommonMark\Extension\CommonMark\Node\Inline\Image; | ||
use League\Config\ConfigurationInterface; | ||
|
||
class ImageAltProcessor | ||
{ | ||
public function __construct(protected ConfigurationInterface $configuration) | ||
{ | ||
} | ||
|
||
public function __invoke(DocumentParsedEvent $documentParsedEvent): void | ||
{ | ||
foreach ($documentParsedEvent->getDocument()->iterator() as $node) { | ||
if (!$node instanceof Image) { | ||
continue; | ||
} | ||
|
||
$baseRoute = $this->configuration->get('formwork/baseRoute'); | ||
|
||
$site = App::instance()->site(); | ||
|
||
$uri = $node->getUrl(); | ||
|
||
$key = $this->configuration->get('formwork/imageAltProperty'); | ||
|
||
$alt = $site->findPage($baseRoute)?->files()->get($uri)?->get($key); | ||
|
||
if ($alt !== null) { | ||
$node->data->set('attributes/alt', $alt); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.