Skip to content

Commit

Permalink
pass image as default param when 'Local only' disabled; fix #231
Browse files Browse the repository at this point in the history
  • Loading branch information
faisal-alvi committed May 13, 2024
1 parent 68fe6bb commit 9a150d2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions includes/class-simple-local-avatars.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,13 @@ public function get_avatar_data( $args, $id_or_email ) {
}

// Local only mode
if ( ! $simple_local_avatar_url && ! empty( $this->options['only'] ) ) {
$args['url'] = $this->get_default_avatar_url( $args['size'] );
if ( ! $simple_local_avatar_url ) {
$default_url = $this->get_default_avatar_url( $args['size'] );
if ( ! empty( $this->options['only'] ) ) {
$args['url'] = $default_url;
} else {
$args['default'] = $default_url;
}
}

if ( ! empty( $args['url'] ) ) {
Expand Down Expand Up @@ -1470,6 +1475,7 @@ public function add_avatar_default_field( $defaults ) {
<input type="hidden" name="simple-local-avatar-file-id" id="simple-local-avatar-file-id" value="<?php echo ! empty( $default_avatar_file_id ) ? esc_attr( $default_avatar_file_id ) : ''; ?>"/>
<input type="hidden" name="simple-local-avatar-file-url" id="simple-local-avatar-file-url" value="<?php echo ! empty( $default_avatar_file_url ) ? esc_url( $default_avatar_file_url ) : ''; ?>"/>
<input type="button" name="simple-local-avatar" id="simple-local-avatar-default" class="button-secondary" value="<?php esc_attr_e( 'Choose Default Avatar', 'simple-local-avatar' ); ?>"/>
<p class="description"><?php esc_html_e( 'Please make sure the avatar is publicly available.', 'simple-local-avatar' ); ?></p>
<?php
$defaults['simple_local_avatar'] = ob_get_clean();

Expand Down

0 comments on commit 9a150d2

Please sign in to comment.