Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/#1923-470-introduced-a-slow-query-from-avatar-alt-text-Add-option-to-filter-avatar-alt #1961

Conversation

ojopaul
Copy link
Collaborator

@ojopaul ojopaul commented Dec 16, 2024

Description

4.7.0 introduced a slow query from avatar alt text, Add option to filter avatar alt fix

Benefits

We introduced the below code/filter to get_custom_avatar so user can return custom alt for avatar to prevent us running a function to get avatar alt text from the image url

        /**
         * Filters avatar alt.
         *
         * Passing a non-null value will prevent us fetching for avatar alt.
         *
         * @param string $avatar_alt text for the author's avatar. Default null.
         * @param Author $author The author's instance.
         * @param array $urls The avatar urls.
         * @param int $size The size of the avatar.
         *
         * @since 4.7.3
         *
         */
        $alt = apply_filters('multiple_authors_avatar_alt_text', null, $this, $urls, $size);
        if (is_null($alt)) {
            $imageId = attachment_url_to_postid($urls['url']);
            $alt = get_post_meta( $imageId, '_wp_attachment_image_alt', true );
        }

to fix #1923

Possible drawbacks

Applicable issues

#1923

Checklist

  • I have created a specific branch for this pull request before committing, starting off the current HEAD of development branch.
  • I'm submitting to the development, feature/hotfix/release branch. (Do not submit to the master branch!)
  • This pull request relates to a specific problem (bug or improvement).
  • I have mentioned the issue number in the pull request description text.
  • All the issues mentioned in this pull request relate to the problem I'm trying to solve.
  • The code I'm sending follows the PSR-12 coding style.

@ojopaul ojopaul merged commit 425952e into development Dec 16, 2024
1 of 4 checks passed
@ojopaul ojopaul deleted the fix/#1923-470-introduced-a-slow-query-from-avatar-alt-text-Add-option-to-filter-avatar-alt branch December 16, 2024 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4.7.0 introduced a slow query from avatar alt text, Add option to filter avatar alt
1 participant