-
-
Save anonymous/8bf9a9460d499e97046d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function check_small_image() { | |
/** | |
* Get our meta value for the image | |
* We use get_the_ID() to get the currently used loop post | |
*/ | |
$small_image = get_post_meta( get_the_ID(), 'small-image-meta', true ); | |
/** | |
* Check if there was actualy an image stored | |
*/ | |
if ( $small_image ) { | |
/** | |
* An image was found, we use the printf() function to | |
* output and sanitize our values to avoid exploits and such | |
*/ | |
printf( | |
'<img src="%s" alt="%s" />', | |
esc_url( $small_image ), | |
__( 'Alternative text', 'textdomain' ) | |
); | |
} | |
else { | |
echo 'Hello'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment