Created
July 22, 2017 21:31
-
-
Save kjohnson/77dbc2e965a2b5d756c11e76c5d51064 to your computer and use it in GitHub Desktop.
Adds a shortcode wrapper for wp_get_attachment_image.
This file contains hidden or 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
| <?php | |
| // ... | |
| /* | |
| * [attachment_image]246[/attachment_image] | |
| */ | |
| add_shortcode( 'attachment_image', 'my_attachment_image' ); | |
| function my_attachment_image( $atts, $content = false ){ | |
| if( ! $content || ! is_numeric( $content ) ) return; | |
| $atts = shortcode_atts( array( 'size' => 'thumbnail', 'icon' => false, 'attr' => '' ), $atts ); | |
| return wp_get_attachment_image( $content, $atts[ 'size' ], $atts[ 'icon' ], $atts[ 'attr' ] ); | |
| } | |
| // ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment