/** * Retrieve image URL with the properly-sized thumbnail. * * @see get_post_meta, wp_get_attachment_image_src * * @param string $slug Optional. CMB tail ID. * @param int $pid Optional. Post ID. * @param string $post_type Optional. Post Type identifier. * @return string Image URL. */ public static function thumbnail($slug = 'image_id', $pid = '', $post_type = '') { if (empty($pid)) { $pid = get_the_id(); } if (empty($post_type)) { $post_type = get_post_type(); } $img_id = get_post_meta($pid, cmb_prefix($post_type) . $slug, true); $img = wp_get_attachment_image_src($img_id, $post_type . '-thumb'); return $img[0]; }
public function test_cmb_prefix() { $slug = 'portfolio'; $this->assertEquals('_cmb2_portfolio_', cmb_prefix($slug)); }