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

Asset URLs have the site root twice #2032

Closed
wratke opened this Issue Jun 22, 2018 · 8 comments

Comments

Projects
None yet
4 participants
@wratke

wratke commented Jun 22, 2018

I'm using Statamic in a folder (http://localhost/site_folder) and it's working well, but the URLs for all of the images (even the images that came with the initial installation) look like this: http://localhost/site_folder/site_folder/path/to/image.jpg. The thumbnails show up in the Asset section of of the control panel, but the images aren't displayed when I go to edit them.Describe the bug
A clear and concise description of what the bug is.

I removed the code that adds the siteroot if the hosting is local from the absoluteUrl method in the Asset.php file and now it works for as expected. I haven't tested it in production yet.

@jasonvarga

This comment has been minimized.

Member

jasonvarga commented Jun 26, 2018

What's site/settings/system.yaml's locales array?

What's index.php's $site_root variable?

How are you hosting the site?

@wratke

This comment has been minimized.

wratke commented Jun 26, 2018

The locales array looks like this:

locales:
en:
full: en_US
name: English
url: 'http://localhost/ninesixteen_cms/'

The site root is set to this:

$site_root = '/ninesixteen_cms/';

I'm hosting it locally with Ampps.

@jasonvarga

This comment has been minimized.

Member

jasonvarga commented Jun 26, 2018

That looks fine. How about the site/content/assets/[your container].yaml file?

@wratke

This comment has been minimized.

wratke commented Jun 26, 2018

I have two containers (it was also doing the same thing with the default Main container which I didn't modify at all).

I have Grid Images:

path: grid_images
url: grid_images
title: 'Grid Images'
fieldset: grid_images

and Core Services:
path: core_services
url: core_services
title: 'Core Services'

@wratke

This comment has been minimized.

wratke commented Jun 26, 2018

This is what I removed from the absoluteUrl method in the statamic/core/Assets/Asset.php file in order to get it working on my local setup:

if ($this->driver() === 'local') {
$url = URL::prependSiteRoot($url);
}

@jasonvarga

This comment has been minimized.

Member

jasonvarga commented Jun 26, 2018

Yup, that'll do it.
This only happened if you had an absolute url defined in system.yaml.

Thanks for your help, it'll be in the next release.

@jesseleite

This comment has been minimized.

Member

jesseleite commented Jun 26, 2018

Just new'ed up statamic app in sub-folder, and hosting with Homestead. Followed the instructions here, and threw this in the redwood homepage template:

{{ assets container="main" }}
    <pre>Url: {{ link :to="url" }}<br>Permalink: {{ permalink }}</pre>
{{ /assets }}

Which gives me this:

screen shot 2018-06-26 at 4 28 10 pm

And serving those permalinks works fine 🤔

@jesseleite

This comment has been minimized.

Member

jesseleite commented Jun 26, 2018

Oh ignore that last comment, I see!

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