ux icon indicating copy to clipboard operation
ux copied to clipboard

[LazyImage] data_uri_thumbnail filename

Open mpiot opened this issue 3 years ago • 1 comments

In the documentation we can see a snippet of code, that explain how to use data_uri_thumbnail, but this one is wrong, because internally the https://github.com/symfony/ux-lazy-image/blob/main/BlurHash/BlurHash.php use the file_get_content function that is relative to this file.

That's why in Twig we need to write the full path, that is not convenient.

<img
    src="{{ data_uri_thumbnail('public/image/large.png', 100, 75) }}"
    {{ stimulus_controller('symfony/ux-lazy-image/lazy-image') }}
    data-hd-src="{{ asset('image/large.png') }}"

    {# Using BlurHash, the size is required #}
    width="200"
    height="150"
/>

For this case, there is 2 option:

  1. We can do on our side, create a Twig global like below, and use it in Twig, maybe update the doc in this case
    globals:
        projectDir: '%kernel.project_dir%'
  1. Use the Project dir at start point to find the file
  2. I just miss something ?

mpiot avatar Nov 26 '21 20:11 mpiot

I also experienced the same error. I think this has to be done internally so using it with asset() would be easier

mathiasayivor avatar Apr 23 '22 15:04 mathiasayivor

Thank you for this issue. There has not been a lot of activity here for a while. Has this been resolved?

carsonbot avatar Apr 26 '24 12:04 carsonbot