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

Wrap Image Field $src in asset #75

Open
toddvalentine opened this issue Aug 12, 2017 · 3 comments
Open

Wrap Image Field $src in asset #75

toddvalentine opened this issue Aug 12, 2017 · 3 comments

Comments

@toddvalentine
Copy link

toddvalentine commented Aug 12, 2017

Can we wrap the $src below from Bkwld's Image field in the asset method so it plays nice with Laravel sub-directory installs? Bkwld\Decoy\Fields\Image::renderEditor()

        if ($src = Former::getValue($this->inputName('file'))) {
            $src = Croppa::url($src, 1050);
        }

Tried using the container to override and running into issues with private methods and instances being new'd up instead of being made from the container.

@weotch
Copy link
Member

weotch commented Aug 16, 2017

Yeah I could, I'm surprised this would be enough of a fix, though. Are you not using the Croppa helpers on your public site? How is your Laravel configured so that asset() fixes it for you? Or does it just happen automatically with no configuration?

Just trying to find the most comprehensive fix possible with these questions.

Relates a bit to #63

@toddvalentine
Copy link
Author

toddvalentine commented Aug 16, 2017

I am using a couple different strategies to tackle the sub-directory issue.

I have created a Service Provider:

    public function register()
    {
        $this->app['path.public'] = base_path().DIRECTORY_SEPARATOR.'public';

        if (App::environment(['staging'])) {
            $this->app['path.public'] = '/site.com/my/path';

            $path =  '/site.com/my/path/uploads';

            $this->app['config']->set('upchuck.disk.path', $path);
            $this->app['config']->set('croppa.src_dir', $path);
            $this->app['config']->set('croppa.crops_dir', $path);
        }

        if (App::environment(['production'])) {

        }
    }

I have also set up a env var that I change based on environment that I use in config/decoy/core to properly get path for assets and in config/decoy/site to properly set nav paths.

The asset wrap would cover the instance where the image is not showing in the admin

@toddvalentine
Copy link
Author

To get correct routes to destroy, I have also had to customize the shared footer haml files to use

%a.btn.btn-danger.delete(href=DecoyURL::relative('destroy', $item->id))
				%span.glyphicon.glyphicon-trash.glyphicon
				!= __('decoy::form.actions.delete')

to

%a.btn.btn-danger.delete(href=URL::to(DecoyURL::relative('destroy', $item->id)))
				%span.glyphicon.glyphicon-trash.glyphicon
				!= __('decoy::form.actions.delete')

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

2 participants