onigoetz / imagecache Goto Github PK
View Code? Open in Web Editor NEWImage generation with presets inspired from Drupal's Imagecache
License: MIT License
Image generation with presets inspired from Drupal's Imagecache
License: MIT License
Hi,
I like this package a lot, just included it in a first project.
I don't like to use retina.js since it tries to find .@2x images from ALL the images on the website. This results in a huge amount of 404 on every page.
I've been using this little piece of JQuery for years now:
// hires images
if (window.devicePixelRatio == 2) {
var images = $("img.hires");
// loop through the images and make them hi-res
for(var i = 0; i < images.length; i++) {
// create new image name
var imageType = images[i].src.substr(-4);
var imageName = images[i].src.substr(0, images[i].src.length - 4);
imageName += "@2x" + imageType;
//rename image
images[i].src = imageName;
}
}
It will replace only the images with the class 'hires'. This way I'm in charge of which images can be @2x.
It will never result in a 404 this way.
The stranges thing happens when I use this imagecache package. As soon as browsercaching is ON. I get 404 errors on all the retina images in the console. However, the correct (@2x) images ARE loaded!
I enable browsercache like this (on NGINX):
location ~* \.(?:ico|css|js|gif|jpe?g|png|woff|ttf|otf|svg|woff2|eot)$ {
expires 1y;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
Hope anyone can figure out what is going wrong.
Hi Stéphane, I'm trying to install on Laravel, but I'm running into the following error when I run "composer require onigoetz/imagecache:dev-master":
Failed to download onigoetz/imagecache from source: Failed to execute git checkout "408220918675b34e3575109569f691b76907d47a" && git reset --hard "408220918675b34e3575109569f691b76907d47a"
HEAD is now at 4082209... Drop PHP 5.3 support
error: unable to create file tests/Fixtures/result/scale-40-?.png (Invalid argument)
error: unable to create file tests/Fixtures/result/scale-?-60.png (Invalid argument)
fatal: Could not reset index file to revision '408220918675b34e3575109569f691b76907d47a'.
Now trying to download from dist
Installing onigoetz/imagecache (dev-master 4082209)
Downloading: 100%
[RuntimeException]
Can you please look into this, and let me know how I can install the package?
on image creation image headers are incorrect
this can be fixed by using $transfer->getHeaders()
instead of $transfer->getFormattedHeaders()
in the laravel service provider https://github.com/onigoetz/imagecache/blob/master/src/Support/Laravel/ImagecacheServiceProvider.php#L61
HTTP/1.1 200 OK
Host: localhost:8000
Connection: close
X-Powered-By: PHP/5.5.9-1ubuntu4.5
0: Content-Type: image/png
1: Content-Length: 3145
2: Expires: Mon, 02 Feb 2015 04:20:42 GMT
3: Cache-Control: max-age=1209600, private, must-revalidate
4: Last-Modified: Mon, 19 Jan 2015 04:20:42 GMT
5: ETag: 77f3b78e2a9de243f010a93fc3536a01
Cache-Control: no-cache, private
Date: Mon, 19 Jan 2015 04:20:42 GMT
Content-Type: text/html; charset=UTF-8
Set-Cookie: laravel_session=eyJpdiI6InJ6VG9QbVJja3JJWlZjQ2pJTzdOV3c9PSIsInZhbHVlIjoiVTZscllMYkdUWmxnRXl0U05pY09xOUFHU3Nib29tWWJ4Y2YwdUN1N0RzU2VSQzVsdEtJeHhVYmlmUVQzZ3k4MnQySHFMSHVUeGF4cnEyMTNkN3BEaVE9PSIsIm1hYyI6IjA5MmE1NDc0NjUyOTNlMTM5YWFhY2UyMmY1MGVmNjI5ZjMxYmVlYjE3NTZhYzQzMGRjNDhlMDIyNjUxMzdmYjkifQ%3D%3D; expires=Mon, 19-Jan-2015 06:20:42 GMT; Max-Age=7200; path=/; httponly
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.