Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SVGs, once again, don't have dimensions #3700

Closed
xjoke opened this issue May 12, 2021 · 3 comments · Fixed by #3702
Closed

SVGs, once again, don't have dimensions #3700

xjoke opened this issue May 12, 2021 · 3 comments · Fixed by #3702
Labels

Comments

@xjoke
Copy link

xjoke commented May 12, 2021

Bug Description

After getting access to SVG dimensions (#2865) and fixing parsing problems (#3479), they were taken from us once more (#3609) a fortnight ago. Please give them back to us 🙏

cms/src/Assets/Asset.php

Lines 534 to 538 in 595e191

public function dimensions()
{
if (! $this->isImage()) {
return [null, null];
}

cms/src/Assets/Asset.php

Lines 586 to 590 in 595e191

public function ratio()
{
if (! $this->isImage()) {
return null;
}

Environment

Statamic 3.1.13 Pro
Laravel 8.41.0
PHP 7.4.16

@duncanmcclean
Copy link
Member

I'm guessing (not tested this) that if you add svg to this array, it starts working again?

https://github.com/statamic/cms/blob/3.1/src/Assets/Asset.php#L345

@xjoke
Copy link
Author

xjoke commented May 12, 2021

Yes, it does. However, since SVGs have so far been kept distinct from other images (e.g. also in the Assets Tag) it might be preferable to add && ! $this->isSvg() to the conditions?

cms/src/Tags/Assets.php

Lines 140 to 142 in 595e191

if ($type === 'svg') {
return $value->isSvg();
}

@duncanmcclean
Copy link
Member

Good catch, that's probably a better fix. Feel free to submit a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants