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 allowing change to the default file extension expected #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

benvoynick
Copy link
Collaborator

This PR adds a hook to change the file format expected by the plugin in its search for images. This can address issue #19 as well as any other format someone would care to use for a site.

@Warface
Copy link

Warface commented Oct 18, 2024

Nice work. I've made some change in the main.php so you can put an array of extension instead and load jpg,png and webp.

`
$extensions = ['jpg', 'png', 'webp'];

// Loop through each extension to check if the image exists
foreach ( $extensions as $ext ) {
    $image_path = get_stylesheet_directory() . '/' . $path . '/' . $layout . '.' . $ext;
    $image_uri = get_stylesheet_directory_uri() . '/' . $path . '/' . $layout . '.' . $ext;

    // Check if the image exists for the current extension
    if ( is_file( $image_path ) ) {
        return $image_uri;
    }
}`

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.

2 participants