Martijn Geerts Posted September 13, 2013 Share Posted September 13, 2013 Today needed a simple way to add text to an image. I ended up serving a page with images headers. So using this image from other pages is: <img src="<?= $pages->get(1234)->url; ?>" /> Settings for the template: - not using a slash at the end - enable template caching - be shure you end the page name with .png .gif or .jpg example code --- Maybe someone comes in the same situation 3 Link to comment Share on other sites More sharing options...
horst Posted September 13, 2013 Share Posted September 13, 2013 Martijn, sometimes I need some more headers, if not already set with apache or to override the apaches default. Maybe you find it useful. // collect infos $maxAge = (60 * 60 * 24 * 2); // 48 hours $imgTimestamp = filemtime($imgFilename); $imgExpiration = intval(time() + $maxAge); // create headers $imgHeaders = array(); $imgHeaders[] = 'Content-type: image/jpeg'; // or other type $imgHeaders[] = 'Content-Length: ' . filesize($imgFilename); $imgHeaders[] = 'Date: ' . gmdate('D, d M Y H:i:s',time()) . ' GMT'; $imgHeaders[] = 'Last-Modified: ' . gmdate('D, d M Y H:i:s',$imgTimestamp) . ' GMT'; $imgHeaders[] = 'Expires: ' . gmdate('D, d M Y H:i:s', $imgExpiration) . ' GMT'; $imgHeaders[] = 'pragma: cache'; $imgHeaders[] = "Cache-Control: max-age={$maxAge}"; //$imgHeaders[] = "Cache-Control: no-transform, public, s-maxage={$maxAge}, max-age={$maxAge}"; // public|private // send header foreach($imgHeaders as $imgHeader) header($imgHeader); 1 Link to comment Share on other sites More sharing options...
Martijn Geerts Posted September 13, 2013 Author Share Posted September 13, 2013 Great, will add that to the gist when I have more time. There're people over here. ( to addicted to pw had to look ) ps, maybe you can help me out with headers in MarkupCSSCompress module to. It still needs some love. (setting good 304 headers) Link to comment Share on other sites More sharing options...
Martijn Geerts Posted September 14, 2013 Author Share Posted September 14, 2013 I added the headers to gist. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now