static function ln($str) { if (WPHF::_is_array($str)) { foreach ($str as $s) { self::ln($s); } } echo $str . PHP_EOL; }
function query_images($query, $size, $type, $default_id, $default_size, $tip_key, $src_keys = array('src', 'width', 'height')) { $images = get_children($query); if (!empty($images)) { foreach ($images as $id => &$image) { $image = (array) $image; if (!empty($image)) { $file = wp_get_attachment_image_src($id, $size); if (WPHF::_is_array($file)) { $image['file'] = WPHF::array_combine_uneven($src_keys, array_values($file)); $image['file']['title'] = $image[$tip_key]; $image['file']['alt'] = $image['post_title']; $image['file']['id'] = WPHF::underscore("{$size} {$image['post_title']}"); $image['file']['class'] = $type; } } else { unset($image); } } } else { $file = wp_get_attachment_image_src($default_id, $default_size); $image = array(); $image['file'] = WPHF::array_combine_uneven($src_keys, array_values($file)); $image['file']['alt'] = 'default'; $image['file']['id'] = WPHF::underscore("{$size} default"); $image['file']['class'] = $size; $images[] = $image; } return $images; }