Advertisement
firoze

sized images through wordpress option tree meta box

Apr 20th, 2015
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. // How to show specific sized images through wordpress option tree meta box
  2.  
  3. // register your gallery type meta box and use the following code to display images.
  4.  
  5. if ( function_exists( 'ot_get_option' ) ) {
  6. $images = explode( ',', get_post_meta( get_the_ID(), 'field-id', true ) );
  7. if ( !empty( $images ) ) {
  8. foreach( $images as $id ) {
  9. if ( !empty( $id ) ) {
  10. $full_img_src = wp_get_attachment_image_src( $id, 'your-image-size' );
  11. $thumb_img_src = wp_get_attachment_image_src( $id,'your-image-size' );
  12. echo '
  13. ';
  14. }
  15. }
  16. }
  17. }
  18.  
  19.  
  20. In line no 4 the field-id is your meta box id.
  21. You can define as much as image sizes you want with your-image-size which you can see in the line no 08 & 09 . The your-image-size is your image id which you created by add_image_size() function in the functions.php .
  22. Thank You!
  23.  
  24.  
  25.  
  26.  
  27. // source link:http://www.wpfreeware.com/tutorial/how-to-show-custom-sized-images-through-wordpress-option-tree/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement