Coder Social home page Coder Social logo

Comments (10)

reganlawton avatar reganlawton commented on September 1, 2024 1

@maxfenton I have updated with v3.0.2. The core package embed/embed seems to have changed a ton of keys and such and I'm using a ton of fallback mappings.

This is a fallback hack BUT if you have images with any particular URL and provider sites just let me know.

from oembed.

reganlawton avatar reganlawton commented on September 1, 2024 1

@maxfenton This is because the image is the same just has a high res and standard res. This will be a embed/embed issue they choose, this why I've just given a fallback so code isn't breaking.

As for ddev craft update all I would personally never do that but that'd because I don't trust things lol but I looked up the docs, as I use a standard custom Dockerfile, but you can just use ddev composer update or ddev composer update wrav/oembed this will not update your plugins major versions which IMHO is very bad that that is the case.

You will still have to set the composer.json to "wrav/oembed": "2.*", manually to revert BUT it shouldn't impact your site as there isn't any custom SQL used. That said always test in a DEV environment.

I'll still be fixing v2.x-dev for bit longer but anything major feature wise will go to v3 aka master branch

from oembed.

maxfenton avatar maxfenton commented on September 1, 2024 1

@reganlawton I finally realized there was an easy enough fix for what I was trying to do, using the media.images you added above:

{#
Note about thumbnailUrl logic:
  - check if the author has set an image in Craft
  - else check if oEmbed v3 has provided a video thumbnail
    -- iff the thumbnail contains `hqdefault` then it is a youtube video and we want the bigger image
  - if neither of those are present, use the fallback
#}
{% set thumbnailUrl = (subblock.featuredImage.one().url ?? null)
    ??? (subblock.video.media.images[0] ?? null) | replace('hqdefault', 'maxresdefault')
    ??? '/assets/images/video-fallback.jpg' %}

I saw the update on #144 and thought I should come post this. Thank you for the fix above. It didn't get me the full list of YouTube thumbnails, but I can hack it with a string replace.

And now I can update to v3 of the plugin without breaking anything. :)

from oembed.

maxfenton avatar maxfenton commented on September 1, 2024

This is a breaking change: 273ed21

from oembed.

reganlawton avatar reganlawton commented on September 1, 2024

@maxfenton Thats why it was set to v3.0.0 a major release, normal used for breaking change or major changes.

The core package was completely upgraded to unblock other plugins that were needing embed/embed v4.

I do understand that some things may have changed but that is due to relying on the core package embed/embed.

I will update the doc in the README to reflect this but v2 of this plugin will still get bugfixes. New features will continue to v3+

from oembed.

maxfenton avatar maxfenton commented on September 1, 2024

@reganlawton Is there a plan to add entry.field.media.images and other existing API data to this plugin? We have code that relies on entry.field.media.images and then picks the largest image as a placeholder for videos.

from oembed.

maxfenton avatar maxfenton commented on September 1, 2024

Also, I think Craft has a way to mark a plugin version as needing some specific change or approval. At the moment craft update all will go straight from 2.3.0 to 3.0.1 despite it being a major semver update.

from oembed.

maxfenton avatar maxfenton commented on September 1, 2024

So in this example, the thumbnail image for a video preview is set by first a custom field the author can edit, then by the largest of the images in oEmbed's entry.field.media.images array (or the first one), and then a fallback image.

{% if videoThumbnail %}
  {% set video = video | merge({
    thumbnail: videoThumbnail,
  }) %}
{% elseif (subblock.video.media.images ??? false) %}
  {% set videoThumbnails = subblock.video.media.images | multisort('size', direction=SORT_DESC) %}
  {% set videoThumbnail = videoThumbnails | filter(image => image.width / image.height == 16/9)[0] ?? videoThumbnails[0] ?? null %}
  {% set video = video | merge({
    thumbnailUrl: videoThumbnail ? videoThumbnail.url : videoThumbnailFallbackUrl,
  }) %}
{% else %}
  {% set video = video | merge({
    thumbnailUrl: videoThumbnailFallbackUrl,
  }) %}
{% endif %}

With oEmbed 2.3.0, the logic above would take the video https://www.youtube.com/watch?v=Limpr1L8Pss and provide https://i.ytimg.com/vi/Limpr1L8Pss/maxresdefault.jpg as the preview image, but now .images doesn't exist.

Edit: I will try 3.0.2, thank you

from oembed.

reganlawton avatar reganlawton commented on September 1, 2024

Have you tried the latest version v3.0.2 I believe

from oembed.

maxfenton avatar maxfenton commented on September 1, 2024

This is the output of {% dd(subblock.video.media.images) %} with 2.3.0:
Screenshot 2023-12-04 at 9 22 26 AM

And this is the output of {% dd(subblock.video.media.images) %} with 3.2.0:
Screenshot 2023-12-04 at 9 29 27 AM

Is there any way in the CraftCMS plugin to set a mark for a breaking change that doesn't automatically update? ddev craft update all tries to update oembed 2.3.0 => 3.0.3 despite the composer.json being specifically set to ^2.3.0

from oembed.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.