lautr.com

Hannes Blog for Development and Stuff besides

5. Februar 2010
von Hannes
5 Kommentare

Display Image count like, picture x of y in WordPress

In a recent Situation i needed to display the attachments of an WordPress Post, the Images, in a click-through-like manner. I also decided to display the current number in relation to the full number of Images you are currently looking at, like a simple “Picture 5 of 7″. Since there is no build in Option for that I had to build my own.

function getNumberOfSiblings($parentid){
$images = (get_children(array(
'post_parent' 	=> $parentid,
'post_type' 	=> 'attachment',
'post_mime_type'=> 'image',
)));
return count($images);
}

function getCurrentNumberOfSibling($parentid,$siblingid){
$images = (get_children(array(
'post_parent' 	=> $parentid,
'post_type' 	=> 'attachment',
'post_mime_type'=> 'image',
)));
if($images[$siblingid]->menu_order != 0){
return $images[$siblingid]->menu_order;
}else{
$i = count($images);
foreach($images as $image){
if($image->ID ==$siblingid){
return $i;
}
$i--;
}
}
}

I mainly just use the get_children function, in the first case to count all the returned siblings and in the second case to get the Position of the current Attachment I use the menu_order Attribute of that matter.

2. Februar 2010
von Hannes
1 Kommentar

include css/js minification in the release process

>> Update <<

I noticed that in the most scenarios you have to always delete the minified file. So i added a line to the script let it take care of that.

First, I love the YUI Compressor , its just a great, yet simple tool, unfortunately it can only handle one File (input) at the Time so I wrote a small Bash Script (thx @ sw) to handle that matter:

#!/bin/bash
rm ${!#};
i=$#
for argument in $@ ;do
if [ $argument != ${!#} ]
then
java -jar yuicompressor-2.4.2.jar $argument >> ${!#}
fi
done

Its really a great Thing to include in your Release Process, if you are like me, use an rsync script or something like that to not have all the svn stuff in your productive directory, or a lot of other possible scenarios, of course!

28. Januar 2010
von Hannes
1 Kommentar

Howto develop a simple, yet nice, Studi VZ Application

First of all, i found it rather interesting how scrambled the Information’s are you can find on that Subject are, but i think you can break it down to 2 Points:

So, after some Hours you will, i got an confirmation mail from the friendly fellows over at VZ. So, lets set the Goals for what I want to accomplish here:

Weiterlesen →