From 61701f305bd2350ccef910265491d0202849a472 Mon Sep 17 00:00:00 2001 From: Lukas Juhas Date: Tue, 17 Jan 2017 12:04:02 +0000 Subject: [PATCH] update get_post_thumbnail_url function, 2.0.3 --- CHANGELOG.md | 4 ++-- functions.php | 16 ++++++++++------ package.json | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c2e384..412acb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,15 +1,15 @@ # barebones changelog +## 2.0.3 +* update get_post_thumbnail_url function and add ability to get specific size. ## 2.0.2 * Add dependencies that were missing while using yarn ## 2.0.1 - * Comment out example "add_image_size" as it can be easily forgotten which leaves you with extra unused image size. * Add CHANGELOG.MD to track changes * Tidy up formatting using PHP-CS-Fixer (mostly spacing) * Update README.MD dependencies ## 2.0.0 - * Refreshed tooling using Elixir with lots of improvements diff --git a/functions.php b/functions.php index 4f8362a..88adc02 100644 --- a/functions.php +++ b/functions.php @@ -177,12 +177,16 @@ add_filter('tiny_mce_before_init', 'barebones_tiny_mce_before_init'); /** * Get post thumbnail url - * - * @param int $post_id - * @return string + * @param string $size Size of the returned image + * @param int $post_id post id + * @param boolean $icon if no image found, display icon */ - -function get_post_thumbnail_url($post_id) +function get_post_thumbnail_url( $size = 'full', $post_id, $icon = false ) { - return wp_get_attachment_url(get_post_thumbnail_id($post_id)); + if(!$post_id) { + $post_id = get_the_ID(); + } + + $thumb_url_array = wp_get_attachment_image_src(get_post_thumbnail_id( $post_id ), $size, $icon); + return $thumb_url_array[0]; } diff --git a/package.json b/package.json index 41ad999..006970f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "barebones", - "version": "2.0.2", + "version": "2.0.3", "author": "Benchmark Studios", "description": "A lightweight and skeletal WordPress boilerplate theme for HTML5 and beyond", "license": "MIT",