Jump to content

Recommended Posts

Posted

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

  • Like 3
Posted

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);
  • Like 1
Posted

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)

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...