Title: Return pre-defined image
Last modified: April 12, 2020

---

# Return pre-defined image

 *  Resolved [AlfaOmega](https://wordpress.org/support/users/alfaomega/)
 * (@alfaomega)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/return-pre-defined-image/)
 * Hey All 🙂
    I’m trying to use Block Lab to display images instead of a text value.
   Can someone please advise what would be the best way to go here. Ex if a use 
   a multi-select and select a couple of text values I want a pre-defined image 
   to be displayed in the front end? Thanks

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Plugin Author [Ryan Kienstra](https://wordpress.org/support/users/ryankienstra/)
 * (@ryankienstra)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/return-pre-defined-image/#post-12663948)
 * Hi [@alfaomega](https://wordpress.org/support/users/alfaomega/),
    Thanks for 
   bringing this up.
 * Maybe this isn’t what you had in mind.
 * But how about:
 * **Fields**
 * Multi-select, with these options:
    Foo Bar Baz Example
 * Image Field 1
 * Image Field 2
 * **PHP Template**
 * If the multi-select value is Foo or Bar, display Image Field 1
    If the multi-
   select value is Baz or Example, display Image Field 2
 *  Thread Starter [AlfaOmega](https://wordpress.org/support/users/alfaomega/)
 * (@alfaomega)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/return-pre-defined-image/#post-12665962)
 * Hi Ryan,
    Thanks for your super fast reply. That is exactly what I need: If the
   multi-select value is Foo, display Image 1 If the multi-select value is Bar, 
   display Image 2
 * The challenge I’m having is setting it up in the PHP as it conflicts with the
   return values.
 * can you please advise what will be the correct line of code for his?
 * Many Thanks
 *  Plugin Author [Ryan Kienstra](https://wordpress.org/support/users/ryankienstra/)
 * (@ryankienstra)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/return-pre-defined-image/#post-12668792)
 * Hi [@alfaomega](https://wordpress.org/support/users/alfaomega/),
    Good to hear!
 * Hm, if there is a multi-select field named `foo-multiselect`, then maybe:
 *     ```
       $text = block_value( 'foo-multiselect' );
       if ( in_array( 'Foo', $text, true ) ) { // If the multiselect has 'Foo' selected
           block_field( 'image-field-1' );
       }
       ```
   
 *  Plugin Author [Ryan Kienstra](https://wordpress.org/support/users/ryankienstra/)
 * (@ryankienstra)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/return-pre-defined-image/#post-12668794)
 * `block_value()` gets the value, while `block_field()` echoes the value
 *  Thread Starter [AlfaOmega](https://wordpress.org/support/users/alfaomega/)
 * (@alfaomega)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/return-pre-defined-image/#post-12669037)
 * Hi Ryan,
    Thanks a lot for your answer. Is there also an option to display a 
   pre-defined image file from a url – (www.google.com/image.jpg), instead of a 
   field? My apologies for bothering you, but I’m a novice and still learning a 
   lot about PHP. Many Thanks
 *  Plugin Author [Ryan Kienstra](https://wordpress.org/support/users/ryankienstra/)
 * (@ryankienstra)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/return-pre-defined-image/#post-12669566)
 * Hi [@alfaomega](https://wordpress.org/support/users/alfaomega/),
    No problem,
   I’m glad you’re using Block Lab 🙂
 * Sure, you could hard-code that in the template, or add it via a URL field:
    [https://getblocklab.com/docs/fields/url/](https://getblocklab.com/docs/fields/url/)
 *  Thread Starter [AlfaOmega](https://wordpress.org/support/users/alfaomega/)
 * (@alfaomega)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/return-pre-defined-image/#post-12674474)
 * Thank You Ryan,
    This is my best plugin so far. It saved me a ton of manual work
   and editing. Keep up the great work
 *  Plugin Author [Ryan Kienstra](https://wordpress.org/support/users/ryankienstra/)
 * (@ryankienstra)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/return-pre-defined-image/#post-12675339)
 * Thanks, that made my day!

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Return pre-defined image’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/block-lab_5c34e8.svg)
 * [Block Lab](https://wordpress.org/plugins/block-lab/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/block-lab/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/block-lab/)
 * [Active Topics](https://wordpress.org/support/plugin/block-lab/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/block-lab/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/block-lab/reviews/)

 * 8 replies
 * 2 participants
 * Last reply from: [Ryan Kienstra](https://wordpress.org/support/users/ryankienstra/)
 * Last activity: [6 years, 1 month ago](https://wordpress.org/support/topic/return-pre-defined-image/#post-12675339)
 * Status: resolved