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

Multi-site locale in asset path => file not found #1304

Closed
wm-simon opened this issue Feb 5, 2020 · 12 comments
Closed

Multi-site locale in asset path => file not found #1304

wm-simon opened this issue Feb 5, 2020 · 12 comments

Comments

@wm-simon
Copy link

wm-simon commented Feb 5, 2020

My sites config:

    'sites' => 
    [
        'de' => [
            'name' => config('app.name') . ' - DE',
            'locale' => 'de_DE',
            'url' => '/de/',
        ],
        'en' => [
            'name' => config('app.name') . ' - EN',
            'locale' => 'en_US',
            'url' => '/en/',
        ]
    ]

The asset path contains now the locale and the file could not be found.

https://domain.tld/de/path/to/file.jpg
@jasonvarga
Copy link
Member

Asset path where? Are you using a tag? Seeing something in the CP?

Please provide some more details.

@wm-simon
Copy link
Author

wm-simon commented Feb 5, 2020

The image is shown in the cp. The image is shown correctly in the frontend, if I remove the locale from path (/de). So I think, it's an mod_rewrite problem. For the assets the locale should not be added to the image path.

@jasonvarga
Copy link
Member

Got it, thanks.

@wm-simon
Copy link
Author

wm-simon commented Feb 5, 2020

Do you have a workaround for it? Would really help!

@jasonvarga
Copy link
Member

I think it's because the default site is a subdirectory (/de) and asset URLs are being generated relative to that. A workaround (not a great one) is to make your default site / instead of /de.

@wm-simon wm-simon changed the title Multi-site local in asset path => file not found Multi-site locale in asset path => file not found Feb 6, 2020
@jasonvarga
Copy link
Member

What are you expecting to be at the root though if both sites live in subdirectories?

@wm-simon
Copy link
Author

Sorry, i think my issue was unclear, I try to explain it better.
I have a multi-site like in my ticket described. I've added an assets field for an image, using the default asset container. If I choose now an image and glide adds the locale to the image url. Without glide the url is correct and the image is shown.
Regular: /img/asset/image.jpg
Glide: /de/img/asset/image.jpg
So if I use glide, the image could not be found from the browser.

@jasonvarga
Copy link
Member

I understand that, but put aside the image stuff for a second. What are you expecting to see when you visit the root?

@jasonvarga
Copy link
Member

Note to self:
https://github.com/statamic/cms/blob/master/src/Imaging/GlideUrlBuilder.php#L61
Removing the site url prepending "fixes" it - it doesn't prepend the site anymore, but it will need some more testing against multiple sites. Especially when using different domains.

@SKuipers
Copy link
Contributor

Note to self:
https://github.com/statamic/cms/blob/master/src/Imaging/GlideUrlBuilder.php#L61
Removing the site url prepending "fixes" it - it doesn't prepend the site anymore, but it will need some more testing against multiple sites. Especially when using different domains.

I had the same issue where a localized multi-site was returning the wrong url for image assets in the non-default site. Your GlideUrlBuilder.php fix worked well. What kind of testing needs done to see this fix make it into the beta? Thanks!!

@jonassiewertsen
Copy link
Contributor

I did use the following workaround:
#1842

It seems, that it would be a cleaner solution to change the path here:
https://github.com/statamic/cms/blob/master/src/Imaging/GlideUrlBuilder.php#L61

@jasonvarga
Copy link
Member

Fixed by #2379

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