Skip to content

URL args get dropped when URL is already a Tachyon URL #61

@pdewouters

Description

@pdewouters

Environment: Altis v3 / Tachyon plugin 0.11.1

I have a custom field on the user profile managed by CMB2 - it's a file upload field

	$cmb->add_field( [
		'name' => esc_html__( 'Author Portrait', 'dormakaba' ),
		'id' => 'dormakaba-author-portrait',
		'type' => 'file',
		'on_front' => false,
	] );

On opening the media modal to select the image, the image URL is like https://example.com/tachyon/2020/09/3.jpg

Then we output the image with a resize parameter
$resized_url = tachyon_url( $attachment_url, [ 'resize' => '90,90' ] );

However the tachyon_url function has a conditional check

if ( strpos( $image_url, $upload_baseurl ) !== 0 ) {
   return $image_url;
}

which means that it will not add the query parameters.

The workaround is to use the attachment ID which is also stored by CMB2 wp_get_attachment_image_url( $attachment_id, 'dk-hero-portrait-image' );

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions