Giter Club home page Giter Club logo

Comments (10)

rolandstarke avatar rolandstarke commented on July 18, 2024

Hey, thanks.

The config looks good.
The problem is when calling ->url() it is actually not checked if the crop is there.

You could use ->url(true); to ensure the crops presence. docs

A problem of this would be that it slows down the ->url call.

The intended workflow would be that every 404 from the digital ocean space would forward the request to your laravel application (but I see digital ocean does not offer that feature) or one generates the crop at upload time.

from laravel-thumbnail.

Askancy avatar Askancy commented on July 18, 2024

Thank you so much, the image is properly stored, even if it generates db9 folders etc... Obligatory this thing?

--- Unfortunately the images generates them with private permits. --- fixed by adding string 'visibility' => 'public' in filesystem

I take the opportunity of your availability to ask you another question, digitalocean's cdn has a url like:
https://***.ams3.digitaloceanspaces.com/projectx/

can i print the correct url with the package:cdn.domain.tdl? also because the url stays extended, and the image even if generated doesn't show up on the page.

from laravel-thumbnail.

rolandstarke avatar rolandstarke commented on July 18, 2024

The 3 char subdirs (db9) are oblicatory so far. The intention behind it is to prevent too many files in one directory.

Great you could fix the visibility!

With the custom subdomain for the do space i don't really know too. This lib just calls echo Storage::disk('do_spaces')->url('image.jpeg'). So the url generation is outside of this library.

from laravel-thumbnail.

Askancy avatar Askancy commented on July 18, 2024

ok i'm doing a url cleanup and a conversion, i'll generate the url with a function,

i still don't understand why it prints:
<img src="https://projectx.ams3.digitaloceanspaces.com/gamelite/crops/23c/xr26nkme8cs088sg4g88kk.webp%3Fcrop%3D150x150%26format%3Dwebp%26p%3Darticolo%252F06e0676974c5981a729328a99d598cb7.jpg%26s%3Dld">

instead of

<img src="https://projectx.ams3.digitaloceanspaces.com/gamelite/crops/23c/xr26nkme8cs088sg4g88kk.webp">

repeats me the path and name of the original file... %3Fcrop%3D150x150%26format%3Dwebp%26p%3Darticolo%252F06e0676974c5981a729328a99d598cb7.jpg%26s%3Dld

Thank you so much, the packages works really well, I really hope it helps me solve the problem of the final printed url so I can start implementing it completely in the project.

from laravel-thumbnail.

rolandstarke avatar rolandstarke commented on July 18, 2024

Ty, sorry. Mm you are right, if the crop is already there the params in the url are no longer needed so you could remove everything after the ? like:


{{ strstr(Thumbnail::src('projectx/article/00b9c8c0e4123c441353050cceafb173.jpg', 'do_spaces')->url(true), '?', true) }}

The main idea of this lib was just that the blade does:
echo 'cropedimage5.jpeg?width=10&heigth=10&originalImage=source.jpeg';

Then when the client tries to load the image the server checks if cropedimage5.jpeg exists and serves it, if it does not exist it would generate the crop from the given params and store the result to cropedimage5.jpeg thats why the params are in the url.

from laravel-thumbnail.

Askancy avatar Askancy commented on July 18, 2024

Ok thank you so much Roland! fixed with:

<img src="{{ re_cdn(Thumbnail::src('projectx/article/003515a5bbf55b9b434e00afb3313d74.jpg', 'do_spaces')->url(true)) }}">

function re_cdn($e) {
	return str_replace("projectx.ams3.digitaloceanspaces.com", "cdn.projectx.net", strstr($e, '%', true));
}

fantastic packages

from laravel-thumbnail.

Askancy avatar Askancy commented on July 18, 2024

Everything works perfectly, but I'm having a load issue, let me know of course if I have to open a new ticket for this.

Since I inserted the thumbnail cutout on the fly, my TTFB has increased a lot, reaching 3.6 seconds.

https://gtmetrix.com/reports/gamelite.it/XO4WT8p6/

basically, this is one of many crop facts:

<img data-src="{{ re_cdn(Thumbnail::preset('news')->src(''.$value->immagine(), 's3')->url(true)) }}" class="lazyload">

the "true" I need to make thumbnails generate when it doesn't exist, i don't understand why it's so slow at loading...

problem itself pure a local and after applying this packages. :(

from laravel-thumbnail.

rolandstarke avatar rolandstarke commented on July 18, 2024

Hey,

I can confirm that it is slow with ->url(true) in combination with an external storage. The slow part here is checking if the thumbnail already exists.

I tested on digital ocean with the do spaces:

   //first test: filesystem is not touched, just the url is generated
    $start = microtime(true);
    for ($i = 0; $i < 30; $i++) {
        Thumbnail::src('https://picsum.photos/200')->url();
    }
    var_dump(microtime(true) - $start);  //<1ms

    //second test: it is checked on the local filesystem if the thumbnail is there
    $start = microtime(true);
    for ($i = 0; $i < 30; $i++) {
        Thumbnail::src('https://picsum.photos/200')->url(true);
    }
    var_dump(microtime(true) - $start); //1ms

    //third test: it is checked on the do spaces if the thumbnail is there
    $start = microtime(true);
    for ($i = 0; $i < 30; $i++) {
        Thumbnail::preset('news')->src('https://picsum.photos/200')->url(true);
    }
    var_dump(microtime(true) - $start); //300ms

from laravel-thumbnail.

Askancy avatar Askancy commented on July 18, 2024

so your best choice is to keep the original image on S3 and the thumbnail on server right?

is the configuration correct like that? because it doesn't create my folder...

        'default' => [
            'destination' => ['disk' => 'local', 'path' => 'public/upload/crops/', 'format' => 'webp'],
        ],

blade:

<img data-src="{{ Thumbnail::preset('news')->src('project/'.$value->immagine(), 's3')->url(true) }}" alt="{!! $value->titolo !!}" class="d-flex align-self-center mr-3 thumb-news lazyload">
thank you so much roland

from laravel-thumbnail.

rolandstarke avatar rolandstarke commented on July 18, 2024

'destination' => ['disk' => 'public', 'path' => '/upload/crops/'],

Should place the files in storage/app/public/upload/crops/

Don't forget to symlink the public dir with php artisan storage:link. now the public disk is served under. public/storage/

from laravel-thumbnail.

Related Issues (13)

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.