Skip to content

Instantly share code, notes, and snippets.

@zachseifts
Created January 21, 2010 21:22
Show Gist options
  • Save zachseifts/283213 to your computer and use it in GitHub Desktop.
Save zachseifts/283213 to your computer and use it in GitHub Desktop.
<?php
/** Function fixing a title
*
* On the homepage for Wall to Wall Photos (and I guess other pages) the
* rotating image's title is fucked up and it's really annoying me. Here's
* a function that should fix it.
*
* That way if a title is `IMG_S4_500` it would be transformed into
* 'No Title'. When a title is `file_name` it will be transformed into
* `File Name`.
*
* Where this is placed is unknown to me at the moment, only because I don't
* have my public key in in my authorized_hosts for this machine. I think It
* should be put somewhere around template.php and override the hook that
* controls object titles, hook_title or something.
*
* @param string $title
* @return string
**/
function fix_title($title) {
if (strlen(strstr($title, 'IMG')) > 0) {
// First of fix the 'IMG' titles.
return 'No Title';
} elseif (count(explode(' ', $title)) == 1) and (strlen(strstr($title, '_')) > 0) {
// Now fix the 'file_name' ones.
$title = explode('_', $title);
return ucwords(implode(' ', $title));
};
return $title;
// like nothing happened.
};
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment