Skip to content
Permalink
Browse files

Extend wfx_get_image - new post_id param

Add post_id parameter - useful for use in custom queries.
  • Loading branch information...
Jonnyauk committed Aug 14, 2019
1 parent c7e64a2 commit 6f00e4045be6c89f55b6b89f897268ed4f4e3695
Showing with 15 additions and 4 deletions.
  1. +2 −2 functions.php
  2. +13 −2 wf-includes/wf-display-functions.php
@@ -1294,7 +1294,8 @@
* @since 2.6
* @version 2.6
*
* @param [string] $id Post ID, ACF field key or options table key (see $field param)
* @param [string] $id Post ID or database field key (options/postmeta/ACF) (see $field param)
* @param [integer] $post_id Post ID when using database field key for $id
* @param [string] $size Size of image to fetch (in-built or custom image size)
* NOTE: Set as array to fetch different images for landscape[0], portrait[1] or square[2] depending upon original format of image
* NOTE: If you set an array, YOU MUST supply 3 values in array, even if they are all the same definitions!!
@@ -1308,7 +1309,6 @@
* @param [string] $return Type of data to return:
* - 'path' default behaviour, just returns string of image path (if valid)
* - 'detail' returns array with keys of 'path', 'width' and 'height' of image
* @param [string] $echo Echo or return output. Y/N [N]
*
* @return [mixed] $return = 'path' returns string with URL of image (checked if valid URL, but not escaped - so remember your esc_url()!)
* $return = 'detail' returns array (see $data param documentation)
@@ -2296,7 +2296,8 @@ function wf_get_attachments($args) {
* @since 2.6
* @version 2.6
*
* @param [string] $id Post ID, ACF field key or options table key (see $field param)
* @param [string] $id Post ID or database field key (options/postmeta/ACF) (see $field param)
* @param [integer] $post_id Post ID when using database field key for $id
* @param [string] $size Size of image to fetch (in-built or custom image size)
* NOTE: Set as array to fetch different images for landscape[0], portrait[1] or square[2] depending upon original format of image
* NOTE: If you set an array, YOU MUST supply 3 values in array, even if they are all the same definitions!!
@@ -2327,6 +2328,7 @@ function wf_get_image( $args ) {
$defaults = array (
'id' => '',
'post_id' => '',
'size' => 'thumbnail',
'field' => 'post_meta',
'fallback' => '',
@@ -2371,7 +2373,16 @@ function wf_get_image( $args ) {
if ( $field == 'post_meta' ) {
$data = get_post_meta( get_the_ID(), esc_attr( $id ), true );
if ( !empty( $post_id ) ) {
$data = get_post_meta( $post_id, esc_attr( $id ), true );
wfx_debug($post_id, 'INSIDE FUNCTION');
} else {
$data = get_post_meta( get_the_ID(), esc_attr( $id ), true );
}
} elseif ( $field == 'option' ) {

0 comments on commit 6f00e40

Please sign in to comment.
You can’t perform that action at this time.