コード例 #1
0
 /**
  * Thumbnail column value added to category admin.
  * @param  string $columns
  * @param  string $column
  * @param  int    $id
  * @return array
  */
 public function food_menu_cat_column($columns, $column, $id)
 {
     if ('thumb' == $column) {
         $thumbnail_id = get_restaurantpress_term_meta($id, 'thumbnail_id', true);
         if ($thumbnail_id) {
             $image = wp_get_attachment_thumb_url($thumbnail_id);
         } else {
             $image = rp_placeholder_img_src();
         }
         // Prevent esc_url from breaking spaces in urls for image embeds
         // Ref: http://core.trac.wordpress.org/ticket/23605
         $image = str_replace(' ', '%20', $image);
         $columns .= '<img src="' . esc_url($image) . '" alt="' . esc_attr__('Thumbnail', 'restaurantpress') . '" class="wp-post-image" height="48" width="48" />';
     }
     return $columns;
 }
コード例 #2
0
/**
 * Get the placeholder image.
 * @return string
 */
function rp_placeholder_img($size = 'food_thumbnail')
{
    $dimensions = rp_get_image_size($size);
    $thumb_size = $dimensions['width'] == 100 ? 'small' : 'large';
    return apply_filters('restaurantpress_placeholder_img', '<img src="' . rp_placeholder_img_src($thumb_size) . '" alt="' . esc_attr__('Placeholder', 'restaurantpress') . '" width="' . esc_attr($dimensions['width']) . '" class="restaurantpress-placeholder wp-post-image" height="' . esc_attr($dimensions['height']) . '" />', $size, $dimensions);
}