Comments (10)
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.
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.
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.
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.
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.
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.
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.
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.
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.
'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)
- Images not viewable for chmod permissions HOT 3
- Relative URL HOT 2
- Folder no exist HOT 2
- Source is not allowed. Given path HOT 5
- Passing null to parameter #1 ($string) of type string is deprecated HOT 1
- implement dont-crop HOT 1
- Scoped filesystem driver not compatible HOT 6
- Delete single thumbnail HOT 1
- Update to php 8 HOT 1
- FR: Support FILESYSTEM_CLOUD as an alternate to $disk
- Port for path HOT 1
- need resize function HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-thumbnail.