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

`AssetUploaded` Event Saves Meta Info with Leading `/` #2165

jcohlmeyer opened this Issue Sep 8, 2018 · 0 comments


None yet
2 participants

jcohlmeyer commented Sep 8, 2018

Describe the bug
Saving an image within the AssetUploaded event in the root of a container adds a leading / to the file name in the the meta info where as a file in a sub folder does not get a leading /.

This results in the meta info for the asset not being read back properly.

For example In the YAML file that has the meta info for the files. The file in the root directory as listed as:

  alt: bar

Files within folders are saved like this:

  alt: foo

To Reproduce
Steps to reproduce the behavior:

  1. Go to add some meta data to an asset in an event listener and save the asset.

namespace Statamic\Addons\AddonName;

use Log;
use Statamic\Extend\Listener;
use Statamic\Events\Data\AssetUploaded;

class AddonNameListener extends Listener {
   * The events to be listened for, and the methods to call.
   * @var array
  public $events = [
    AssetUploaded::class => 'assetUploadedEvent',

  public function assetUploadedEvent(AssetUploaded $event) {
    $asset = $event->asset;
    $asset->data(['alt' => 'Test alt text']);

Expected behavior
No leading / to be on the key for the meta info of images uploaded the the root of a container when saved within the AssetUploaded event.

Environment details (please complete the following information):

  • Statamic Version 2.10.2
  • Fresh Install or Upgrade: Upgrade from 2.something
  • OS: Ubuntu 16.04
  • Browser: Firefox
  • Web Server: Nginx
  • PHP Version: 7.1
  • Addons installed: Audio Embed, Colorpicker, Feed, Google Analytics, Permissions, PowerTools, Sitemap, VideoEmbed

Additional context
Add any other context about the problem here.

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