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 path incomplete when stored on S3 #975

Closed
jasonbell opened this Issue Sep 21, 2016 · 2 comments

Comments

Projects
None yet
3 participants
@jasonbell

jasonbell commented Sep 21, 2016

Expected behaviour

When I select an Asset within an Asset fieldtype on a Collection, I expect that URL returned in templating will display the image.

Actual behaviour

In the template, when printing the Asset URL it omits the path (sub-directory in bucket) section.

Template code:

{{ assets:tile_image }}
  {{ url }}
{{ /assets:tile_image }}

Instead of https://s3.amazonaws.com/BUCKET/PATH/FILE.jpg it prints https://s3.amazonaws.com/BUCKET/FILE.jpg.

Steps to reproduce

  1. Set up an Asset container using S3 driver and specify the bucket and sub-folder
  2. Add an Asset field to a Collection
  3. Create an entry and select/upload an asset (it adds in S3 just fine, the thumbnail is broken)
  4. Set up the template to show this new field similar to above
  5. Observe URL is wrong

Server configuration

Operating system:
OS X 10.11.6

Web server:
MAMP

PHP version:
PHP 5.6.10

Statamic version:
2.1.11

Updated from an older Statamic or fresh install:
Fresh

List of installed addons:
none

@jasonvarga

This comment has been minimized.

Member

jasonvarga commented Sep 22, 2016

Fixed for 2.1.12

It's a one line fix, if you want to patch it yourself until it's released.

In statamic/core/Stache/Drivers/AssetContainersDriver.php line 50, change to:

return rtrim($adapter->getClient()->getObjectUrl($adapter->getBucket(), array_get($data, 'path', '/')), '/');
@jasonbell

This comment has been minimized.

jasonbell commented Sep 22, 2016

Thanks! Been pulling my hair out all day with assets and S3. I’ll check other open issues for S3 related issues that keep popping up.

@jackmcdade jackmcdade closed this Sep 26, 2016

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