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

Add filter for nextgen image format #777 #783

Merged
merged 3 commits into from
Jan 19, 2024

Conversation

Khadreal
Copy link
Contributor

Description

Add imagify_nextgen_images_formats filter

Fixes #777

Type of change

  • New feature (non-breaking change which adds functionality).

Is the solution different from the one proposed during the grooming?

No

Checklists

Generic development checklist

  • My code follows the style guidelines of this project, with adapted comments and without new warnings.
  • I have added unit and integration tests that prove my fix is effective or that my feature works.
  • The CI passes locally with my changes (including unit tests, integration tests, linter).
  • Any dependent changes have been merged and published in downstream modules.
  • If applicable, I have made corresponding changes to the documentation. Provide a link to the documentation.

Test summary

  • I triggered all changed lines of code at least once without new errors/warnings/notices.
  • I validated all Acceptance Criteria of the related issues. (If applicable, provide proof).
  • I validated all test plan the QA Review asked me to.

@jeawhanlee
Copy link
Contributor

@Tabrisrp This PR is dependent on this: #782 no?

@Khadreal Khadreal changed the base branch from develop to feature/avif January 18, 2024 11:51
@Khadreal
Copy link
Contributor Author

@Tabrisrp This PR is dependent on this: #782 no?

To the best of my knowledge, no

Copy link
Contributor

@Tabrisrp Tabrisrp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how I was picturing it so that we can re-use the function whenever we need:

function imagify_nextgen_images_formats() {
    $formats = [
        'webp',
    ];

    if ( get_imagify_option( 'convert_to_avif' ) ) {
        $formats[] = 'avif';
    }

    $default = $formats;
    /**
     * Filters the array of next gen formats to generate with Imagify
     *
     * @since 2.2
     *
     * @param array $formats Array of image formats
     */
    $formats = apply_filters( 'imagify_nextgen_images_formats', $formats );

    if ( ! is_array( $formats ) ) {
        $formats = $default;
    }

    return $formats;
}

@Khadreal
Copy link
Contributor Author

This is how I was picturing it so that we can re-use the function whenever we need:

function imagify_nextgen_images_formats() {
    $formats = [
        'webp',
    ];

    if ( get_imagify_option( 'convert_to_avif' ) ) {
        $formats[] = 'avif';
    }

    $default = $formats;
    /**
     * Filters the array of next gen formats to generate with Imagify
     *
     * @since 2.2
     *
     * @param array $formats Array of image formats
     */
    $formats = apply_filters( 'imagify_nextgen_images_formats', $formats );

    if ( ! is_array( $formats ) ) {
        $formats = $default;
    }

    return $formats;
}

Cool! I was thinking we would use filter in place of calling the function.

@Tabrisrp Tabrisrp merged commit 0a8f547 into feature/avif Jan 19, 2024
1 check failed
@Tabrisrp Tabrisrp deleted the feature/777-avif-support-filter branch January 19, 2024 20:15
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.

AVIF support: filters to manage images formats to generate
4 participants