<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>AjaxMasters Blog &#187; imageroll</title> <atom:link href="http://blog.ajaxmasters.com/tag/imageroll/feed/" rel="self" type="application/rss+xml" /><link>http://blog.ajaxmasters.com</link> <description>Just another WordPress weblog</description> <lastBuildDate>Thu, 24 Jun 2010 11:55:25 +0000</lastBuildDate> <generator>http://wordpress.org/?v=2.9.2</generator> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>Playing with CSS3</title><link>http://blog.ajaxmasters.com/playing-with-css3/</link> <comments>http://blog.ajaxmasters.com/playing-with-css3/#comments</comments> <pubDate>Thu, 01 Oct 2009 18:55:57 +0000</pubDate> <dc:creator>Chocksy</dc:creator> <category><![CDATA[Tutorial]]></category> <category><![CDATA[css]]></category> <category><![CDATA[css3]]></category> <category><![CDATA[imageroll]]></category> <category><![CDATA[shadows]]></category><guid
isPermaLink="false">http://blog.ajaxmasters.com/?p=185</guid> <description><![CDATA[<a
href="http://blog.ajaxmasters.com/playing-with-css3/"><img
align="left" hspace="5" width="150" height="150" src="http://blog.ajaxmasters.com/wp-content/uploads/2009/10/play_css3-170x170.png" class="alignleft wp-post-image tfe" alt="Play with CSS3" title="play_css3" /></a><p>If you saw our "<b>ImageRoll</b>" page and you used Firefox, Chrome or Safari then you saw the images being rotated in different angles well the way i did that is by using CSS3. I guess you already figured that out from the title. :)</p><p>CSS3 implements a lot of new features that can make your life easier of course you will not be able to use them quite yet. IE is not supporting like more than 90% of them so it's useless if you want to make this for a client. The ones that we used on our blog are: <b>box-shadow</b>, <b>border-radius</b> and <b>text-shadow</b>. [...]</p>]]></description> <content:encoded><![CDATA[<div
id="attachment_186" class="wp-caption alignleft" style="width: 249px"><a
href="http://blog.ajaxmasters.com/wp-content/uploads/2009/10/play_css3.png"><img
src="http://blog.ajaxmasters.com/wp-content/uploads/2009/10/play_css3.png" alt="Play with CSS3" title="play_css3" width="239" height="239" class="size-full wp-image-186" /></a><p
class="wp-caption-text">Play with CSS3</p></div><p>If you saw our &#8220;<b>ImageRoll</b>&#8221; page and you used Firefox, Chrome or Safari then you saw the images being rotated in different angles well the way i did that is by using CSS3. I guess you already figured that out from the title. <img
src='http://blog.ajaxmasters.com/wp-content/plugins/smilies-themer/pidgin/smile.png' alt=':)' class='wp-smiley' /></p><p>CSS3 implements a lot of new features that can make your life easier of course you will not be able to use them quite yet. IE is not supporting like more than 90% of them so it&#8217;s useless if you want to make this for a client. The ones that we used on our blog are: <b>box-shadow</b>, <b>border-radius</b> and <b>text-shadow</b>. I think these are the most important of them but you can check all of them out by taking a look at this page: <a
href="http://www.css3.info/preview/" title="http://www.css3.info/preview/">css3.info/preview/</a>.</p><p>I&#8217;m gonna do a simple explanation on the ones we used and show you some code.</p><p>We used on the hrefs of the page this property:</p><pre class="brush: css;">
-moz-box-shadow: 0px 2px 15px #333;
</pre><p>Now let&#8217;s explain. Why &#8220;-moz&#8221; in front of it? This is a simple hack for those who don&#8217;t know it. It tells the browser to render this only in <b>mozilla</b> based browsers. Next we have the property box-shadow  and 0px means the top margin of the shadow, 2px means we move the shadow 2 pixels to the left and 15px<br
/> means we create a shadow with 15 pixels of size of blur if you want, #333 is of course the color of the box shadow. Pretty simple <img
src='http://blog.ajaxmasters.com/wp-content/plugins/smilies-themer/pidgin/smile.png' alt=':)' class='wp-smiley' /> .</p><p>Now let&#8217;s rotate the images:</p><pre class="brush: css;">
   -webkit-transform: rotate(-10deg);
    -moz-transform: rotate(-10deg);
</pre><p>You know -moz- already but we have a new one &#8220;-webkit-&#8221; this one means it will render in webkit based browsers, the most popular are: Safari and Chrome. Next we have the property &#8220;transform&#8221; and the degree of rotation &#8220;-10deg&#8221;.</p><p>The other one that we used all over the blog is text-shadow</p><pre class="brush: css;">
text-shadow:1px 1px 0px #000;
</pre><p>This property is like this 1px means we move the shadow with 1 pixel from the top, 1 pixel from the left and 0 blur or size, #000 means of course the color of the shadow.</p><p>And here is a preview in 2 browsers IE and Firefox so you can see maybe you are not using a browser that supports CSS3.</p><div
id="attachment_193" class="wp-caption aligncenter" style="width: 610px"><a
href="http://blog.ajaxmasters.com/wp-content/uploads/2009/10/ie.png"><img
src="http://blog.ajaxmasters.com/wp-content/uploads/2009/10/ie-600x705.png" alt="Ie view" title="ie" width="600" height="705" class="size-large wp-image-193" /></a><p
class="wp-caption-text">Ie view</p></div><br
/><div
id="attachment_194" class="wp-caption aligncenter" style="width: 610px"><a
href="http://blog.ajaxmasters.com/wp-content/uploads/2009/10/firefox.png"><img
src="http://blog.ajaxmasters.com/wp-content/uploads/2009/10/firefox-600x642.png" alt="Firefox view" title="firefox" width="600" height="642" class="size-large wp-image-194" /></a><p
class="wp-caption-text">Firefox view</p></div><p>My imageroll page is inspired from this page: <a
href="http://line25.com/tutorials/how-to-create-a-pure-css-polaroid-photo-gallery">line25.com/tutorials/how-to-create-a-pure-css-polaroid-photo-gallery</a> . Go and check it out <img
src='http://blog.ajaxmasters.com/wp-content/plugins/smilies-themer/pidgin/good.png' alt='(Y)' class='wp-smiley' /> .</p><p>Thank you and happy coding! <img
src='http://blog.ajaxmasters.com/wp-content/plugins/smilies-themer/pidgin/wink.png' alt=';)' class='wp-smiley' /></p> ]]></content:encoded> <wfw:commentRss>http://blog.ajaxmasters.com/playing-with-css3/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Use ajax to create a cacheing system</title><link>http://blog.ajaxmasters.com/use-ajax-to-create-a-cacheing-system/</link> <comments>http://blog.ajaxmasters.com/use-ajax-to-create-a-cacheing-system/#comments</comments> <pubDate>Tue, 29 Sep 2009 10:49:52 +0000</pubDate> <dc:creator>Chocksy</dc:creator> <category><![CDATA[Tutorial]]></category> <category><![CDATA[cache]]></category> <category><![CDATA[html]]></category> <category><![CDATA[imageroll]]></category> <category><![CDATA[images]]></category> <category><![CDATA[javascript]]></category> <category><![CDATA[php]]></category> <category><![CDATA[plugin]]></category> <category><![CDATA[system]]></category> <category><![CDATA[vi.sualize.us]]></category> <category><![CDATA[wordpress]]></category><guid
isPermaLink="false">http://blog.ajaxmasters.com/?p=163</guid> <description><![CDATA[<a
href="http://blog.ajaxmasters.com/use-ajax-to-create-a-cacheing-system/"><img
align="left" hspace="5" width="150" height="150" src="http://blog.ajaxmasters.com/wp-content/uploads/2009/09/cache-170x170.png" class="alignleft wp-post-image tfe" alt="Cache Pic" title="cache" /></a><p>As I said in my last post, I wanted from the first time to make a cacheing system for my imageroll page. Because i take the images from vi.sualize.us servers and we don't want to make to much trafic and make stuff worse for them.</p><p>So what i did is simple, i made a class that extracts the rss data from theirs servers and get the images to display them. I do this every time someone visits the page.</p>]]></description> <content:encoded><![CDATA[<p><div
id="attachment_164" class="wp-caption alignleft" style="width: 287px"><a
href="http://blog.ajaxmasters.com/wp-content/uploads/2009/09/cache.png"><img
src="http://blog.ajaxmasters.com/wp-content/uploads/2009/09/cache.png" alt="Cache Pic" title="cache" width="277" height="277" class="size-full wp-image-164" /></a><p
class="wp-caption-text">Cache Pic</p></div><p>As I said in my last post, I wanted from the first time to make a cacheing system for my imageroll page. Because i take the images from vi.sualize.us servers and we don&#8217;t want to make to much trafic and make stuff worse for them.</p><p>So what i did is simple, i made a class that extracts the rss data from theirs servers and get the images to display them. I do this every time someone visits the page. If any image is new for the first time we display the image from vi.sualize.us and run a functions in javascript to check for new images. If any new images exist then we cache them in a folder on our server and the next time a user visits the page that image will be shown from our server. Pretty simple.</p><p>For now i&#8217;ll just show you the stuff that makes this thing run and if you want i can share the whole script so that you can make one for your blog or website.</p><p>I&#8217;ll also try to make a WordPress plugin so you can integrate it easily in your blog.</p><p>So here we go. We start with the function that checks for new images:</p><pre class="brush: php;">
functio checkCache($image_url){
            $path=pathinfo($image_url);
            $img_cached = 'cache/'.$path['filename'].'.'.$path['extension'];
            if(!file_exists($img_cached)) {
                createCacheImg($image_url);
            }
}
</pre><p>This function just checks if the image exists in the &#8220;<b>cache</b>&#8221; folder. If it&#8217;s not there then we run the &#8220;<b>createCacheImg</b>&#8221; function.</p><p>We now need a function to get the image so we check if the image is in the cache folder or not so we know what to display.</p><pre class="brush: php;">
    function getImage($or_img) {
        $path=pathinfo($or_img);
        $filename=$path['filename'];
        $img_cached = 'cache/'.$filename.'.'.$path['extension'];
        if(file_exists($img_cached)) {
            $url=$img_cached;
        }else {
            $url=$or_img;
        }

        return $url;
    }
</pre><p>Very simple function that just returns the right url of the image.</p><p>Now we cache the image.</p><pre class="brush: php;">
function createCacheImg($image){
        $srcsize = getimagesize($image);
        $w = $srcsize[0];
        $h = $srcsize[1];

        $path=pathinfo($image);
        $dest='cache/'.$path['filename'].'.'.$path['extension'];
        if($path['extension']=='jpg' || $path['extension']=='jpeg' || $path['extension']=='JPG') {
            $src_img = imagecreatefromjpeg($image);
        }else if($path['extension']=='gif') {
                $src_img = imagecreatefromgif($image);
            }else if($path['extension']=='png') {
                    $src_img = imagecreatefrompng($image);
                }
        $img_cpy=imagecreatetruecolor($w,$h);
        imagecopy($img_cpy, $src_img, 0, 0, 0, 0, $w, $h);
        if($path['extension']=='jpg' || $path['extension']=='jpeg' || $path['extension']=='JPG') {
            imagejpeg($img_cpy,$dest);
        }else if($path['extension']=='gif') {
                imagegif($img_cpy,$dest);
            }else if($path['extension']=='png') {
                    imagepng($img_cpy,$dest);
                }
        imagedestroy($src_img);
}
</pre><p>This function will save the image into the cache folder. Now we need a new file &#8220;<b>checkcache.php</b>&#8221; where we put this code:</p><pre class="brush: php;">
include('functions.php');
$image=$_GET['image'];
checkCache($image);
</pre><p> Right now we should have this kind of structure in our imageroll folder: A folder &#8220;<b>cache</b>&#8221; a file &#8220;<b>functions.php</b>&#8221; where we place all these functions we just did and a file &#8220;<b>index.php</b>&#8221; where we run the javascript function and display the images.</p><p>The &#8220;<b>index.php</b>&#8221; file requires this code:</p><pre class="brush: xml;">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
    &lt;head&gt;

        &lt;title&gt;
            Image ROLL
        &lt;/title&gt;

        &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
        &lt;script src=&quot;http://www.google.com/jsapi&quot;&gt;&lt;/script&gt;
        &lt;script type=&quot;text/javascript&quot;&gt;  google.load(&quot;jquery&quot;, &quot;1.3.2&quot;); &lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
&lt;input type=&quot;hidden&quot; id=&quot;image&quot; value=&quot;http://test.com/image.jpg&quot;&gt;
&lt;img src=&quot;&lt;?=getImage($image)?&gt;&quot; alt=&quot;test image&quot;/&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre><p>We have here a simple index.php file that imports the google api and jquery so we can run a simple ajax function. This is the javascript code that you should insert in this file or a separate one if you want:</p><pre class="brush: jscript;">

            $(document).ready(function() {
                checkCache();
            });

            function checkCache(){
                var page=$('#image');
                var url='checkcache.php';
                var pars='page='+page.val();
                $.get(url,pars);
            }
</pre><p>This will run this function after the page loads and it will check for new images. So this is just a simple script that will make you pages load faster expecialy if you load the images from outside of your server.</p><p>If you liked this i&#8217;ll go and make a more complex one and even share the imageroll script i did. That until i find the time and make a Wordpress Plugin.</p> ]]></content:encoded> <wfw:commentRss>http://blog.ajaxmasters.com/use-ajax-to-create-a-cacheing-system/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced) (user agent is rejected)
Database Caching 5/28 queries in 0.005 seconds using disk

Served from: blog.ajaxmasters.com @ 2010-07-31 13:53:29 -->