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

feat: Remove check for attachment post type that can’t be overridden #85

Merged
merged 4 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/Timmy.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,12 @@ public static function get_image( $attachment, $size ) {
$attachment = (int) $attachment['ID'];
}

if ( 'attachment' !== get_post_type( $attachment ) ) {
// Check if we work with a WordPress post. This doesn’t necessarily have
// to be an attachment, that’s why we don’t check for the 'attachment'
// post type.
$wp_post = \get_post( $attachment );

if ( ! $wp_post ) {
return null;
}

Expand Down
6 changes: 3 additions & 3 deletions tests/test-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function test_get_timber_image_src_without_metadata() {
}

public function test_get_timber_image_src_non_image() {
$result = get_timber_image_src( 'gaga', 'large' );
$result = get_timber_image_src( 0, 'large' );

$this->assertEquals( false, $result );
}
Expand Down Expand Up @@ -64,7 +64,7 @@ public function test_get_timber_image_without_metadata() {
}

public function test_get_timber_image_non_image() {
$result = get_timber_image( 'gaga', 'large' );
$result = get_timber_image( 0, 'large' );

$this->assertEquals( false, $result );
}
Expand Down Expand Up @@ -373,7 +373,7 @@ public function test_get_timber_image_srcset() {
}

public function test_get_timber_image_srcset_non_image() {
$result = get_timber_image_srcset( 'gaga', 'large' );
$result = get_timber_image_srcset( 0, 'large' );

$this->assertEquals( false, $result );
}
Expand Down
Loading