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

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

Open
pdewouters opened this issue Sep 22, 2020 · 1 comment
Open

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

pdewouters opened this issue Sep 22, 2020 · 1 comment

Comments

@pdewouters
Copy link
Contributor

pdewouters commented Sep 22, 2020

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' );

@roborourke roborourke changed the title URL args get dropped when uploads not in path URL args get dropped when URL is already a Tachyon URL Sep 23, 2020
@pdewouters
Copy link
Contributor Author

The workaround won't work when attempting to retrieve an attachment that belongs to another site unless we switch_to_blog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants