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

TimberImage resize() filter broken for Bedrock users (and others?!) #1428

Closed
alicam opened this issue May 23, 2017 · 1 comment
Closed

TimberImage resize() filter broken for Bedrock users (and others?!) #1428

alicam opened this issue May 23, 2017 · 1 comment

Comments

@alicam
Copy link

alicam commented May 23, 2017

I've encountered a bug in TimberImage's conversion of src to a path.

I'm using Bedrock, which is a little "creative" about where things live in the file structure and what they're named.

My wp_upload_dir() function call returns this:

Array
(
    [path] => /Users/alicam/Sites/day3.io/repo/web/app/uploads/2017/05
    [url] => http://day3-io.local/app/uploads/2017/05
    [subdir] => /2017/05
    [basedir] => /Users/alicam/Sites/day3.io/repo/web/app/uploads
    [baseurl] => http://day3-io.local/app/uploads
    [error] => 
    [relative] => /app/uploads
)

At line 373 of ImageHelper.php, this logic is consequently incorrect/inadequate:

			if ( false === strpos($upload_dir['baseurl'], site_url()) ) {
				// use HOME_URL and relative image path
				$tmp = get_home_url().$tmp;
			}

The assumption is made here, that if strpos returns false, it must mean a relative url was given, but that's not the case with Bedrock! Concatenating $tmp with get_home_url() for me therefore incorrectly returns:

http://day3-io.local/http://day3-io.local/app/uploads/.../path/to/my/image.jpg

I managed to resolve this by stripping out the site_url() from the src, before passing it to the resize() filter, but that's only good for now.

I haven't got time to work out a fix, so I'll leave that to someone else for now!

Cheers.

A

@R24-Dev
Copy link

R24-Dev commented May 24, 2017

We just bumped into the same issue. You can also use the relative filter in the Twig-template for now.

{{post.thumbnail.src|relative|resize()}}

@nlemoine nlemoine closed this as completed Mar 8, 2023
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

No branches or pull requests

3 participants