Пример #1
0
 /**
  * Adds our custom fields to the WP edit term form
  * @param $taxonomy Object A WP Taxonomy term object
  * @since 0.8.0
  */
 function edit_fields( $taxonomy ) {
     $this->setup_field_scripts();
     /*?>
     <tr class="form-field">
         <th><label for="s8_tax_order">Sort Order</label></th>
         <td><input type="number" name="s8_tax_order" id="s8_tax_order" size="4" min="0" max="9999" value="<?php echo $taxonomy->term_group; ?>" /></td>
     </tr>*/ ?>
     <tr class="form-field">
         <th><label for="s8_tax_image"><?php _e( 'Image' ); ?></label></th>
         <td>
             <?php $image = s8_get_taxonomy_image_src($taxonomy, 'full'); ?>
             <input type="hidden" name="s8_tax_image" id="s8_tax_image" value="<?php echo ($image)?$image['src']:''; ?>" />
             <input type="hidden" name="s8_tax_image_classes" id="s8_tax_image_classes" value="" />
             <?php $image = s8_get_taxonomy_image_src($taxonomy);  ?>
             <img src="<?php echo ($image)?$image['src']:''; ?>" id="s8_tax_image_preview" style="max-width: 300px;max-height: 300px;float:left;display: <?php echo($image['src'])?'block':'none'; ?>;padding: 0 10px 5px 0;" />
             <a href="#" class="button" id="s8_tax_add_image" style=""><?php _e( 'Add/Change Image' ); ?></a>
             <a href="#" class="button" id="s8_tax_remove_image" style="display: <?php echo ( $image['src'] ) ? 'inline-block' : 'none'; ?>;"><?php _e( 'Remove Image' ); ?></a>
         </td>
     </tr>
     <?php
 }
Пример #2
0
/**
 * Get the html needed to display the taxonomy term image
 * @param Object $tax_term A WP taxonomy term object
 * @param string $size (OPTIONAL) A string specifying the image size to get (e.g. thumbnail, medium, full, or a custom size that has been created by you or a plugin). Does NOT work on images that weren't uploaded through the WP media uploader.
 * @return bool|String returns false on failure, html img string on success
 * @since 0.8.0
 */
function s8_get_taxonomy_image( $tax_term, $size = 'thumbnail' ) {
    $image = s8_get_taxonomy_image_src( $tax_term, $size );
    if ( ! $image ) return false;
    return '<img src="' . $image['src'] . '" alt="' . $tax_term->name . '" class="taxonomy-term-image" width="' . ( ( $image['width'] ) ? $image['width'] : '' ) . '" height="' . ( ( $image['height'] ) ? $image['height'] : '' ) . '" />';
}