The Artima Developer Community
Sponsored Link

Java Buzz Forum
Packaging images in your code

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
dion

Posts: 5028
Nickname: dion
Registered: Feb, 2003

Dion Almaer is the Editor-in-Chief for TheServerSide.com, and is an enterprise Java evangelist
Packaging images in your code Posted: Oct 31, 2005 11:39 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by dion.
Original Post: Packaging images in your code
Feed Title: techno.blog(Dion)
Feed URL: http://feeds.feedburner.com/dion
Feed Description: blogging about life the universe and everything tech
Latest Java Buzz Posts
Latest Java Buzz Posts by dion
Latest Posts From techno.blog(Dion)

Advertisement

Packing up resources can sometimes be a challenge. What if you have a plugin that you want someone to be able to install. Do you make them unpack a set of images/css/... to a certain place?

I recently say a PHP plugin that encapsulated everything it did in the one PHP script. I was wondering where the images were, and then I saw them inline in the PHP code itself!

/**
 * Images
 */
$images = array();
$images['subscribed.png'] = "iVBORw0KGgoAAAANSUhEUgAAABUAAAAICAMAAAAhgUThAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAAGUExURai0vvP8+20m9Z0AAAACdFJOU/8A5bcwSgAAAE5JREFUeNpiYAQBBhBGAgABxAARZYBgRigPIIBgchAI1cgAEEBwFWDlUNMYAAIIWS3cIAaAAEIyFy7OyAAQQAxIbkDYBhBAcCaKywACDAAgyABfpZamZwAAAABJRU5ErkJggg==";
$images['subthread.png'] = "iVBORw0KGgoAAAANSUhEUgAAAA0AAAANCAYAAAEF7NTqAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAACmSURBVHjaYvz//z8DCAAEEBMDFAAEECNMBCCA4CIAAQQXgQGAAGJiQAMAAYSiAiCAGIEYzgMIIBSlAAGEogwggBignP/oGCQOEEAYNiADgADCKwkQQBiOhQGAAGIByzIyosgCFTMCBBBOHQABhFMHQADh1AEQQDh1AAQQTh0AAYRTAh8ACCBEzKBZhY8PEEBMDGQAgAAiSxNAAJGlCSCAyAoIgAADAEniPAbcSIg9AAAAAElFTkSuQmCC";
$images['subthread-open.png'] = "iVBORw0KGgoAAAANSUhEUgAAAA0AAAANCAYAAAEF7NTqAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAACoSURBVHjaYvz//z8DCAAEEBMDFAAEECNMBCCA4CIAAQQXgQGAAGJiQAMAAYSiAiCAQOg/VOA/QAChKAUIIBRlAAHEAFOCjkHiAAGEYQMyAAggvJIAAYThFBgACCAWsCwj4380dzICBBBOHQABhFMHQADh1AEQQDh1AAQQTh0AAYRTAh8ACCBEzKBZhWE6kjxAADExkAEAAogsTQABRJYmgAAiKyAAAgwA3YE+/1F5tWAAAAAASUVORK5CYII=";
$images['spacer.png'] = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQI12NgYGBgAAAABQABXvMqOgAAAABJRU5ErkJggg==";

if(isset($_GET['image']))
{
        header("content-type: image/png");
        print base64_decode($images[$_GET['image']]);
        exit;
}

I never would have thought to encode my images and output them from my script itself. Oh those crazy PHP guys :)

Read: Packaging images in your code

Topic: Sassy Chicken Salad: Eating [Flickr] Previous Topic   Next Topic Topic: Sassy Chicken Salad: Eating [Flickr]

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use