[ENTITY][AttachmentThumbnail] Every image should have width and height attributes
This commit is contained in:
@@ -44,7 +44,7 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
* @copyright 2019, 2021 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
class Embed extends Controller
|
||||
class OEmbed extends Controller
|
||||
{
|
||||
/**
|
||||
* Handle OEmbed server requests
|
@@ -118,8 +118,7 @@ class Embed extends Plugin
|
||||
*/
|
||||
public function onAddRoute(RouteLoader $m): bool
|
||||
{
|
||||
$m->connect('oembed', 'main/oembed', Controller\Embed::class);
|
||||
$m->connect('embed', 'main/embed', Controller\Embed::class);
|
||||
$m->connect('oembed', 'main/oembed', Controller\OEmbed::class);
|
||||
return Event::next;
|
||||
}
|
||||
|
||||
@@ -141,7 +140,7 @@ class Embed extends Plugin
|
||||
'link' => [
|
||||
'rel' => 'alternate',
|
||||
'type' => "application/{$format}+oembed",
|
||||
'href' => Router::url('embed', ['format' => $format, 'url' => $url]),
|
||||
'href' => Router::url('oembed', ['format' => $format, 'url' => $url]),
|
||||
'title' => 'oEmbed',
|
||||
], ];
|
||||
}
|
||||
|
@@ -57,8 +57,6 @@ class AttachmentEmbed extends Entity
|
||||
private ?string $author_name;
|
||||
private ?string $author_url;
|
||||
private ?string $thumbnail_url;
|
||||
private ?int $thumbnail_width;
|
||||
private ?int $thumbnail_height;
|
||||
private \DateTimeInterface $modified;
|
||||
|
||||
public function setLinkId(int $link_id): self
|
||||
@@ -188,12 +186,13 @@ class AttachmentEmbed extends Entity
|
||||
{
|
||||
$attr = ['class' => 'u-photo embed'];
|
||||
$attachment = DB::find('attachment', ['id' => $this->getAttachmentId()]);
|
||||
$thumbnail = $attachment->getThumbnail('medium');
|
||||
if (is_null($attachment) || is_null($attachment->getWidth()) || is_null($attachment->getHeight())) {
|
||||
$attr['has_attachment'] = false;
|
||||
} else {
|
||||
$attr['has_attachment'] = true;
|
||||
$attr['width'] = $attachment->getWidth();
|
||||
$attr['height'] = $attachment->getHeight();
|
||||
$attr['width'] = $thumbnail->getWidth();
|
||||
$attr['height'] = $thumbnail->getHeight();
|
||||
}
|
||||
return $attr;
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@
|
||||
{% if attributes['has_attachment'] != false %}
|
||||
{% set thumbnail_parameters = {
|
||||
'id': embed.getAttachmentId(),
|
||||
'size': 'small'
|
||||
'size': 'medium'
|
||||
} %}
|
||||
<img alt="{{embed.getTitle() | escape}}" class="{{attributes['class']}}"
|
||||
width="{{attributes['width']}}" height="{{attributes['height']}}"
|
||||
|
Reference in New Issue
Block a user