Tag: Featured

Last.fm RPS WordPress Plugin

I’ve completely rewritten the plugin after 8 years, because the code was targeting PHP4 platforms and now it should work with all PHP5+ versions.

Still does the same thing: Its a widget plugin which collects data from Audioscrobbler web services and gets your last listened tracks and their album images.

Download : You can get the latest release here : http://wordpress.org/extend/plugins/lastfm-rps/

Then just activate the plugin, go to Design-Widgets, add the widget where you want, write the username and widget title in the settings and save. That’s all.

Current Version : 2.0.0

Demo : You can see a working example in the right sidebar.

jQuery Scrolite Plugin

This plugin appends a vertical scrollbar to any element which you need to limit its dimensions like an image, a div or an ul list etc. This is the initial release of this plugin, so feel free to test it and give me some feedback so I can update this plugin with new improvements or with bug free versions. (horizontal scrollbar will be added later.)

It uses Brandon Aaron’s beautiful mousewheel plugin for mouse wheel scrolling support.

It can be configured with many ways as scrollbar width, color, edge radius, scrollbar bed width, color, edge radius, scroll panel width, scroll panel height, mouse scroll sensitivity.

File sizes are 7.36 kBytes for the development version, 4.08 kBytes for the minified version (as for alpha stage), and 206 bytes for the CSS file. (The zip file is big because of the included jQuery library and png image.)

Demo

You can see a working example here

Download

You can download the package here (Demo page included):

Installation

Include these lines into your script’s <head> declaration:

<script src="lib/jquery.min.js" type="text/javascript"></script><script src="lib/jquery.scrolite.min.js" type="text/javascript"></script><script src="lib/jquery.mousewheel.js" type="text/javascript"></script>

Usage

Then use this script with :

$(".scrollable").scrolite({
width:500,
height:300
});

It will create something like this:

Options

The plugin options are:

'barColor' : The color of the scrollbar handle
'bedColor' : The color of the scrollbar bed
'bedWidth' : Width of the scrollbar bed
'bedCornerRadius' : CSS3 border-radius of scrollbar bed
'barWidth' : Scrollbar handle width
'barCornerRadius' : CSS3 border-radius of scrollbar handle
'width' : scrollable area width
'height' : scrollable area height
'scrollSensitivity' : pixel scrolling value of one tick of the mousewheel
'bedMarginTop' : pixel margin for top of the scroller bed
'bedMarginBottom' : pixel margin for bottom of the scroller bed
'bedMarginLeft' : pixel margin for left of the scroller bed
'bedMarginRight' : pixel margin for right of the scroller bed

CSS Elements

You can change other CSS values by referring to these classes in your styles file:

'.scrolite' : refers to container of all the elements below
'.scrolite-bed' : refers to scrollbar bed element
'.scrolite-bar' : refers to scrollbar handle element
'.scrolite-container' : refers to the scrollable area wrapper

Public Functions

If you are using an AJAX script to load it’s contents from somewhere, you can refresh the scrollbar’s calculations by this function (included in the demo file):

$(".scrollable").data("scrolite").refresh()

The “.scrollable” refers to your initial element which you’ve added the scrollbar.

 

PHP Animated Gif Resizer

There are many sites that use avatars and sometimes they use animated GIF files. But when it comes to resizing them, it really becomes a pain when your server doesn’t support ImageMagick. So I decided to write an animated GIF resizer based on GD Library (Because GD doesn’t support it directly either.)

It works like this:

  1. Extract frames from GIF animations into a temporary folder.
  2. Resizes all the frames
  3. Combines them into one file

Using this class is really simple. Here is the code

<?php
include_once "gifresizer.php";
$gr = new gifresizer;
$gr->temp_dir = "frames"; //note that it doesn't end with a "/"
$gr->resize("gif/1.gif","resized/1.gif",200,300);

// $gr->temp_dir = {a folder with a write permission (777)}; // The temporary folder which frames will be extracted to.
// $gr->resize({file to be resized}, {new file to be created}, {new width}, {new height});
?>

Here’s an example:

 

Original GIF file :


Resized Image:


Here you can download the class, documentation and examples.

PHPClasses.org class main page

 

Note: I’m expecting some feedback. Here or at phpclasses.org. Doesn’t matter. If you are using it, tell me how it works.

pngfix WordPress Plugin

This plugin uses CSS technique to fix the png image transparency issue and jQuery to apply this script to all of png images shown in the page. The CSS code added by the script is :

.png {
background-image: expression(
this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" + (this.tagName==\'IMG\' ? this[\'src\'] : this.currentStyle[\'backgroundImage\'].split(\'\"\')[1]) + ")",
this.runtimeStyle.backgroundImage = "none",
this.src = "{plugindir}/pixel.gif",
this.width = this.style.width | this.clientWidth,
this.height = this.style.height | this.clientHeight
);
}';

And the jQuery code which applies this css to all of the png images :

$(document).ready(function(){
if(($.browser.msie)&(parseInt($.browser.version)<7)){
$("img[src$='.png']").each(function(){$(this).addClass("png");});
}
});

That’s all. The jQuery library is included in the plugin so you don’t need to modify anything.

Installation is simple. Just follow these steps :

  1. Upload ‘wp-pngfix’ directory to the ‘/wp-content/plugins/’ directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress
  3. Thats all. Go to any page which contains some png images with IE and check if there’s any errors.

This should fix them all except backgrounds now.

Download: Official WordPress plugin page : http://wordpress.org/extend/plugins/wp-pngfix/

Note: This type of fixes cause slight color changes to your png images with background color, so you may have to change some css.If you use images without inner backgrounds and only need to show the background transparent, forget that note 🙂

SimpleXML for PHP4

PHP4 için SimpleXML fonksiyonu ararken diğer yazılmış XML okuyucu classlar dışında pek birşey bulamadım ve en iyisi kendim yazıyım dedim. Nerden başlasam ne etsem derken deneye deneye bu script ortaya çıktı ve PHP5’in simpleXML’i kadar hızlı olmasada aynı işi yapabiliyor. Koda ihtiyacı olanlar için aşağıya ekledim.

Briefly in English:

I wrote a simple script recently that works like simplexml on PHP4 and uses the PHP XML Parser to get local or remote files. It works a little slower than simplexml and maybe we could change foreach to for cycles. and that outputs directly an array not an object so we can use it without any object2array functions.

I moved the codes and the example file to

http://www.phpclasses.org/browse/package/4484.html

so check the address for further updates, bug reports etc.

New! The class is now also at : http://www.phpkode.com/scripts/item/simplexml-for-php4/

Last.fm RPS

Follow me on Twitter

GiottoPress by Enrique Chavez