Tag Archives: comicpress

PHP and ComicPress: Simple way to Retrieve the Latest Comic Image CodeUnit 17 OCT 2011

I have a WordPress/ComicPress-driven web comic site and wanted to show the latest posted comic image on another one of my websites. Because I couldn’t locate anything to return just the latest image for embedding purposes, I quickly whipped up the following PHP script to achieve this for me:

//determing the latest image in the comics folder and redirecting to it if calculated

//get the correct file path to use
$documentRoot =$_SERVER['DOCUMENT_ROOT'];


//set the folder path to the comics folder
$folder = $documentRoot . DIRECTORY_SEPARATOR . 'comics';

//variable to hold the newest image path
$newestImage = '';

//loop through the comics directory. If file, compare the modified time to the currently set newest image. Update accordingly.
if (is_dir($folder)){
	foreach (scandir($folder) as $node) {
		$nodePath = $folder . DIRECTORY_SEPARATOR . $node;
		if (!is_dir($nodePath)){
		    if ($newestImage == ''){
		        $newestImage = $nodePath;
		    } else {
		        if (filemtime($nodePath) > filemtime($newestImage)){
			$newestImage = $nodePath;

//force redirect to the latest file, otherwise print an error message
if (is_file($newestImage)){
	header('location: ' . str_replace($documentRoot . DIRECTORY_SEPARATOR . 'comics','http://' . $_SERVER['SERVER_NAME'] . '/comics',$newestImage));
} else {
	echo '

Unable to determine latest image file.

'; }

Dump the above into a file and place it on your ComicPress server, before simply referencing it in an image tag on your target server. In other words, having saved the above to a file called latestcomicimage.php:

<img src=”http://comicserver.com/latestcomicimage.php” />


Webcomics on WordPress: ComicPress! CodeUnit 05 JAN 2010

By now, we are all familiar with WordPress, the blogging platform that literally revolutionized the web and placed the role of content creator into the hands of millions of everyday, casual users. Funnily enough though, WordPress also lends itself as the ideal way of publishing webcomics and the easiest way to do this is in fact to make use of the brilliant ComicPress theme and associated plugins to do all the work for you.

Courtesy of Tyler Martin, John Bintz and Philip Hofer, ComicPress is a clever WordPress theme that converts your usual blog layout into that of a webcomic site. The theme comes packed with various layout options as well as all the navigation tricks and widgets you’d expect from a comic hosting site and has been structured to be fairly simple to use, even for the most casual of WordPress users.

In addition to the ComicPress theme it is also suggested that you install the ComicPress Manager Plugin as this adds a whole lot of functionality in order to simplify the uploaded and managing of comic files and associated text. Also, a clever little new addition to the family is the ComicPress Companion plugin that essentially provides you with editing tools to update a separate stylesheet which overwrites ComicPress’ default styles, meaning that you can now maintain your custom styles even when upgrading or downgrading between ComicPress versions.

ComicPress really is the Internet standard when it comes to online comic publishing and it simply put, is an indispensable tool to all you would-be comic creators out there. (Hell, even my personal House of C is powered by ComicPress!)

Currently sitting at release 2.8, you can download the latest ComicPress version here.

Related Link: http://comicpress.org/