GravityView  2.9.2
The best, easiest way to display Gravity Forms entries on your website.
field-gravatar-html.php
Go to the documentation of this file.
1 <?php
2 /**
3  * Gravatar field output for HTML rendering
4  *
5  * @global \GV\Template_Context $gravityview
6  * @since TODO
7  */
8 
9 if ( ! isset( $gravityview ) || empty( $gravityview->template ) ) {
10  gravityview()->log->error( '{file} template loaded without context', array( 'file' => __FILE__ ) );
11  return;
12 }
13 
14 $field_settings = $gravityview->field->as_configuration();
15 
16 // There was no email field setting defined somehow.
17 if ( empty( $field_settings['email_field'] ) ) {
18  return;
19 }
20 
22 
23 $settings['email'] = GravityView_Field_Gravatar::get_email( $field_settings, $gravityview->entry->as_entry() );
24 
25 $settings['args'] = array(
26  'force_display' => true,
27 );
28 
29 /**
30  * @filter `gravityview/fields/gravatar/settings` Modify the Gravatar settings for the field
31  * @param[in,out] $settings array Settings passed to {@see get_avatar()} for parameters.
32  * @param \GV\Template_Context $gravityview Current context
33  */
34 $settings = apply_filters( 'gravityview/fields/gravatar/settings', $settings, $gravityview );
35 
36 echo get_avatar(
37  \GV\Utils::get( $settings, 'email' ),
38  \GV\Utils::get( $settings, 'size', 96 ),
39  \GV\Utils::get( $settings, 'default', '' ),
40  \GV\Utils::get( $settings, 'alt', '' ),
41  \GV\Utils::get( $settings, 'args', array() ) // You can set via filter above
42 );
gravityview()
Definition: _stubs.php:26
get( $key, $default=null)
Retrieve a setting.
static get_email( $field_settings, $entry)
Get the email address to use, based on field settings.
if(empty( $field_settings['email_field'])) $settings
if(! isset( $gravityview)||empty( $gravityview->template)) $field_settings
Gravatar field output for HTML rendering.