function z_taxonomy_image($term_id = NULL, $size = 'full', $attr = NULL, $echo = TRUE)
{
    if (!$term_id) {
        if (is_category()) {
            $term_id = get_query_var('cat');
        } elseif (is_tax()) {
            $current_term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
            $term_id = $current_term->term_id;
        }
    }
    $taxonomy_image_url = get_option('z_taxonomy_image' . $term_id);
    if (!empty($taxonomy_image_url)) {
        $attachment_id = z_get_attachment_id_by_url($taxonomy_image_url);
        if (!empty($attachment_id)) {
            $taxonomy_image = wp_get_attachment_image($attachment_id, $size, FALSE, $attr);
        } else {
            $image_attr = '';
            if (is_array($attr)) {
                if (!empty($attr['class'])) {
                    $image_attr .= ' class="' . $attr['class'] . '" ';
                }
                if (!empty($attr['alt'])) {
                    $image_attr .= ' alt="' . $attr['alt'] . '" ';
                }
                if (!empty($attr['width'])) {
                    $image_attr .= ' width="' . $attr['width'] . '" ';
                }
                if (!empty($attr['height'])) {
                    $image_attr .= ' height="' . $attr['height'] . '" ';
                }
                if (!empty($attr['title'])) {
                    $image_attr .= ' title="' . $attr['title'] . '" ';
                }
            }
            $taxonomy_image = '<img src="' . $taxonomy_image_url . '" ' . $image_attr . '/>';
        }
    }
    if ($echo) {
        echo $taxonomy_image;
    } else {
        return $taxonomy_image;
    }
}
function z_taxonomy_image_url($term_id = NULL, $size = NULL, $return_placeholder = FALSE)
{
    if (!$term_id) {
        if (is_category()) {
            $term_id = get_query_var('cat');
        } elseif (is_tax()) {
            $current_term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
            $term_id = $current_term->term_id;
        }
    }
    $taxonomy_image_url = get_option('z_taxonomy_image' . $term_id);
    $attachment_id = z_get_attachment_id_by_url($taxonomy_image_url);
    if (!empty($attachment_id)) {
        if (empty($size)) {
            $size = 'full';
        }
        $taxonomy_image_url = wp_get_attachment_image_src($attachment_id, $size);
        $taxonomy_image_url = $taxonomy_image_url[0];
    }
    if ($return_placeholder) {
        return $taxonomy_image_url != '' ? $taxonomy_image_url : Z_IMAGE_PLACEHOLDER;
    } else {
        return $taxonomy_image_url;
    }
}