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

Class Responsive retrieveAsset method not returning Asset type in Statamic 3.3 #116

Closed
Roberth91 opened this issue Mar 31, 2022 · 1 comment

Comments

@Roberth91
Copy link

I'm trialling an upgrade to Statamic 3.3 (from 3.2) and I've run into an issue where the retrieveAsset function in src/Responsive.php is breaking.

Starting line:57

if ($assetParam instanceof Value) {
    $asset = $assetParam->value();

    if ($asset instanceof Collection) {
        $asset = $asset->first();
    }
}

Since 3.3 update this $asset can be an instance of Statamic\Query\OrderedQueryBuilder I had success when updating the code to the following:

if ($assetParam instanceof Value) {
    $asset = $assetParam->value();

    if (!$asset instanceof Asset) {
        $asset = $asset->first();
    }
}
@jmartsch
Copy link

jmartsch commented Apr 26, 2022

I also got errors after upgrading to Statamic 3.3.
After upgrading this error occurs on some pages with images (but not on all pages):
Call to undefined method Statamic\Assets\OrderedQueryBuilder::extension() E:\htdocs\dotnetic\website\resources\views/partials/sets/image.antlers.html#1

My image.antlers.html file looks like this:

<figure>
  {{ image }}
    {{ responsive:image data-src="{{ url }}" glide:width="768" width="768"  class="{{ class ?? class ?? 'mx-auto' }} lazyload" placeholder="false" loading="lazy" decoding="async" }}
  {{ /image }}
  {{ if caption }}
      <figcaption class="block text-base text-gray-600 text-center max-w-sm mx-auto">{{ caption }}</figcaption>
  {{ /if }}
</figure>

The fix @Roberth91 provided solves this issue.

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

No branches or pull requests

2 participants