to display only files with the extension 'jpg' you would need to put an if statement in your code. without seeing what your code is, something like this should work.
if (strtolower(substr(strrchr($file,"."),1)) == 'jpg') {
echo $file;
}
for your question of 'how to find a directory size?' i got this from the manual.
function dirsize($dirName = '.') {
$dir = dir($dirName);
$size = 0;
while($file = $dir->read()) {
if ($file != '.' && $file != '..') {
if (is_dir("$dirName$file")) {
$size += dirsize($dirName . '/' . $file);
} else {
$size += filesize($dirName . '/' . $file);
}
}
}
$dir->close();
return $size;
}