generated from roots/acorn-example-package
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Ik zag dat de meest gebruikte opties al wel supported waren
namelijk alt en url, maar toevallig moest ik een cover neerzetten en die maken wel vaker gebruik van Captions.
En gezien Caption een wordpress native invoer veld in de mediatheek is, misschien ook goed om daarvoor support te bieden.
File in kwestie:
https://github.com/yardinternet/odmh/blob/feat/further-implementation-initial-design/vendor/yard/data/src/ImageData.php
<?php
declare(strict_types=1);
namespace Yard\Data;
use Spatie\LaravelData\Attributes\MapInputName;
use Spatie\LaravelData\Data;
class ImageData extends Data
{
public function __construct(
#[MapInputName('meta_value')]
public int|string $id,
) {
}
public function alt(string $default = ''): string
{
$alt = get_post_meta((int) $this->id, '_wp_attachment_image_alt', true);
return is_string($alt) && '' !== $alt ? $alt : $default;
}
public function url(string $size = 'medium_large'): string
{
return wp_get_attachment_image_url((int) $this->id, $size) ?: '';
}
}SimonvanWijhe
Metadata
Metadata
Assignees
Labels
No labels