Coder Social home page Coder Social logo

Comments (6)

johannschopplich avatar johannschopplich commented on June 7, 2024

Sorry, but I can't follow or make out the cause of your issue. Please provide an example so I may dig in.

On a side note: You can always crop your image first and generate the placeholder image afterwards: $image->crop(50, 40)->placeholderUri().

from kirby-blurry-placeholder.

carstengrimm avatar carstengrimm commented on June 7, 2024
 <img src="<?= $file->crop(600,400)->placeholderUri() ?>" data-src="<?= $file->focusCrop(600,400)->url() ?>" alt="<?= $file->alt() ?>" width="600" height="400" class="lazyload"> 

with the Crop the placeholderUri is supposed to also be using 600x400px, because when having the lazyload effect, the ratio is not the same with my data-src, which results in the palceholderUri being the original width/height ratio and therefor the image (as well as the surrounding container - quite default column div) will change in size.

Here we can see the placeholderUri, where as the original format of the right picture is portrait. but using the (focus)Crop the final image basically is changed to 600x400 which will then result in the container adjusting the height after lazyloading the image:

2021-09-20_09-20-54

After the Image has been lazyloaded, you can see the outside container with the navigation, obviously get closer to the pictures because the placeholderUri height has been more than the originals, even though i have changed my code to $image->crop(600,400)->placeholderUri()

Where then I would assume this placeholder should also be 600x400

2021-09-20_09-21-13

(the Original Picture is Landscape- so even though i am using the crop function, it still uses the original ratio)

(Maybe there's a slight Caching going on, however see the next comment)

from kirby-blurry-placeholder.

carstengrimm avatar carstengrimm commented on June 7, 2024

Thus i notice when i use the $image->crop(600,400)->placeholderUri() method the src image seems not to load (broken image symbol before lazyload), the output says src(unknown) before lazyload happens.

image

When checking the Sourcecode using

$image->crop(600,400)->placeholderUri()
Results in empty src

<div class="p-4 w-1/3">
 <img src="" data-src="..." class="lazyload">
 </div>

where as

$image->placeholderUri()

outputs the correct data:image/svg....

<div class="p-4 w-1/3">
 <img src="data:image/svg+xml;charset=utf-8...." data-src="..." class="lazyload">
 </div>

I think $image->crop(600,400)->placeholderUri() would be my solution to having the same ratio for the blurry src but it seems there's something not working (for me)

I just did a composer update as well and it seems like i am up-to-date.

from kirby-blurry-placeholder.

johannschopplich avatar johannschopplich commented on June 7, 2024

You are right, using crop() or resize() will not return a \Kirby\Cms\File, rather \Kirby\Cms\FileVersion. Will dig into the latter class and how to parse them for the placeholder URI.

from kirby-blurry-placeholder.

carstengrimm avatar carstengrimm commented on June 7, 2024

At the very beginning i thought maybe placeholderUri(600,400) may be available, then I also played around with resize, focuscrop, crop, but since that kinda broke the whole thing i was directly using the palceholderUri whereas we can see the different ratio from here

#11 (comment)

so finally make an issue, came back finally finding crop/resize not functioning with placeholderUri, which is a step forward already.

Quite the roundabout. Sometimes it's a challenge finding the issue :-)

from kirby-blurry-placeholder.

johannschopplich avatar johannschopplich commented on June 7, 2024

Added an option to pass the image ratio to the placeholder methods. See https://github.com/johannschopplich/kirby-blurry-placeholder#cropped-images.

Please update to v1.4.0. Thanks!

from kirby-blurry-placeholder.

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.