@dangayle

PHP Code: Cite your photo sources!

After working on a site that uses images from a variety of different sources, I felt that it was appropriate to cite the sources. (I do come from a newspaper background, so…)

So, what was the best way to do it?

Since the image is being hotlinked from another source, I could do a string search of the domain, then display the appropriate link. Easy enough, right?

It’s not so easy, since you have to search for a variety of sources, then know the link to display. That’s where a PHP array comes in handy.

Here’s the example:

Code Example

<?php
//Creates link to image source for creative attribution
$photoSource = array(
        'wikimedia'=> '<a href="http://commons.wikimedia.org/" rel="nofollow external">Wikimedia Commons</a>',
        'flickr'=> '<a href="http://www.flickr.com" rel="nofollow external">Flickr</a>',
        'picasa'=> '<a href="http://picasaweb.google.com/" rel="nofollow external">Picasa</a>',
   );
foreach ($photoSource as $photoSource_origin => $photoSource_link) {
if (stristr($imagePath,$photoSource_origin)) { ?>
   <p class="image_source">Image courtesy of < ?php echo $photoSource_link; ?></p>
<?php break; }
}?>

Code Explained

You create your array of possible sources, the example here uses Wikimedia Commons, Flickr, and Picasa as examples.

The foreach ($photoSource as $photoSource_origin =&gt; $photoSource_link) loop associates each photo source with its corresponding link. The if (stristr($imagePath,$photoSource_origin)) searches the $imagePath variable, which is the variable that contains the link to the photo, for the terms listed as $photoSource, and if found, then display’s the found search term’s associated link, the $photoSource_link.

The break then stops the loop after a solution is found.

Cool solution huh?

PHP Programming

I know this makes me a real nerd, but I’m starting to almost understand a little about web programming using PHP. (I know, sad id’nit?)

I started out learning but customizing my WordPress blog, this blog, which of course is written in PHP. As I got into it, I started learning how bits and pieces started coming together. (Forget PHP, creating this blog is a large part of where I learned HTML to begin with!)

Now with some of the stuff I do at work, I use basic PHP a lot more. Stuff like if.. else.. conditional statements, basic loops, server side includes, things of that nature. If you have no idea what any of that means, don’t worry, even I didn’t a while back. I’m still learning how arrays work, how sql queries work, cookies, etc. More intermediary concepts.

I’m reading a lot, and learning a lot about how things work on the web. With that comes some obligations, I feel, to help others. That is why I’m going to start writing some basic PHP tutorials to show how the basics work. Keep an eye out for the first tutorials soon!

In the meantime…

Until I get started writing tutorials about PHP, I highly recommend that you get the book PHP Solutions from Friends of Ed. Great book!

RTF Stern

Jim Rimmer in Vancouver, BC has done something that no one else has done before:

He’s the first person to release a font both digitally and in metal at the same time, which is quite a feat. Since all of the metal typefounders are old, they don’t typically get into the whole “computer” thing. And vice-versa.

RTF Stern, by Jim Rimmer

Here’s a video produced by Richard Kegler of the P22 Type Foundry

The Wall-E Movie was awesome

Finallly, a graphics heavy movie that actually focuses on the stinkin’ story line. (Thank you, Pixar!)

Since moving to Spokane, I’ve seen more movies than I have seen in two or three years living in Spokane. I’m starting to figure out why I never watched too many movies before: Most of them were stupid. A lot of the newest movies I’ve seen confirmed that point for me: stupid.

But not Wall-E.

That movie was awesome. The graphics were awesome, the characters were awesome, and most importantly, the story was awesome. In typical Pixar fashion, the story is not compromised by the desire to have “flashy graphics” (ahem, here’s lookin’ at you Star Wars Ep I and II).

I love this movie to death. I never thought I could love a little trash compactor so much! The humanization of the robots in the story is spot-on perfect, so much so that you forget that you’re watching a completely CG character. Which, in my opinion, is the only viable option if you want me to actually like the movie.

Bring your kids, because it’s fun for the whole familia, without the unnecessary perversity and crudeness that plagues even kids movies these days.

Parallel Histories font

I never posted this before, but I figure it’s never too late. This typeface comes from the handwriting of Juan de Yciar of Spain, circa 1600 C.E. The book that these scans came from is in the Library of Congress, and it is easily one of the greatest looking pieces of handwriting I have ever seen.

Over 80+ pages of this scribal penmanship, beautifully illuminated and decorated, with gilt images and touches of flair throughout. It would seem to be appropriate for a great Spanish love story, but it’s actually quite mundane :)

Since it is Spanish, there were quite a few letters that didn’t exist, such as the maguscule and miniscule K, which is a sound that it taken care of by the letter Q in that language. (And look at that Q! That’s the non-swash variant!)

Overall, there are something like 400+ glyphs, including a tremendous amount of ligatures and swashes that are all coded in Opentype. I’m still working on just the basic latin character set and the spacing before I can unleash it into the wild.

Reblog this post [with Zemanta]

Golfing with the friends

Here’s a little putt putt minigolf outing of my friends and me at *Wonderland* in Spokane, Wa. It’s the first time I’ve ever edited a video digitally and uploaded to Youtube. It was fun!

I shot everything using my Canon Powershot G9, an awesome little camera. As you can see, the video quality is great. I bought the camera, though, because it is one of the only point-and-shoots that actually will shoot in RAW format. As a photographer, I highly appreciate that ability. The standard .JPEGs kind of suck, but that’s not what I bought it for to begin with.

I’ll have to do more videos, since that was super easy, and fun to boot!

Greek Letterforms

I’ve recently been working on a font similar to Trajan, based off of the letterforms found on the cover of Joy Division’s Closer album. What I thought would be fun would be to add Greek uppercase letters to match, and eventually Cyrillic.

This is not about that font.

But in my research, I came across a super cool Greek inscription that, to my eyes, is heavy metal before metal was heavy (Did that make sense?) I thought that it would be fun to start digitizing this example as well.


I don’t know how many letters I’ll need to build from scratch, but it shouldn’t be too hard, as everything is built out of similar parts. Look for it sometime, uh, whenever.

Sigur Ros’ Heima DVD

New DVD Rocks!

(In an Icelandic way)

Sigurros_heima
I just watched Sigur Rós’ new video Heima at a friend’s house. It was awesome! I was on the list from the band’s management to be at the screening here in Seattle, but I missed it. I’ve been waiting for this movie ever since I saw a preview for it a few months back.

I’ve been listening to the double album that they released at the end of ’07, and I’ve been in anticipation for a while. Luckily, my friend had a projector and a killer sound system to watch and listen to it.

It gets a touch, shall we say, slow at points, and sometimes I wish they wouldn’t cut from the music so much, but it was still great. (And I haven’t seen the 2nd disc yet, which has full versions of all of the songs!) It was nice seeing the country of Iceland too. Lots and lots of nothing.

I’m now officially Sigur Róssed-out.

New year, New design

So it’s the end of 2007. Huzzah! The Seahawks are in the playoffs again. I’m working, if only temporarily, at the Seattle Times, and things are looking good.

My friend Jonathan sat down with me to work on a new budget to help me reach my financial goals, so starting Jan 1 I’ll have to start being more fiscally responsible. Eh.

In any case, it’s time to roll out a new design for the ol’ webpage.  Looks like I spoke too soon. Serious CSS errors have been found! I was looking over at wpdesigner’s website (I actually wrote a few articles for him a few months back) and I came across a nice new tutorial that he had put together. It’s called How to Code a WordPress Theme, and it is much better than his former tutorials.

I followed it all the way through during a sleepless night, and what you behold now is the results. Pretty snazzy, eh? I customized it quite a bit, although you can still see the remnants of his Wrath wordpress theme that he used in his tutorial.
new theme screenshot
As you can see from the screenshot, it actually started as a theme I wanted to design for our website Geek-vs-Life.com, but I ran into some difficulties along the way. It works great for my needs though. I’ll be continually tweaking it as I go along,  (It’s busted!) and eventually I guess I should release it, if Small Potato is cool with it. We’ll see.

<h5>editt</h5>

Serious stinking css errors have delayed the emergence of my new theme. Drats!

Recent tweets

Pages