Git Product home page Git Product logo

media's People

Contributors

gmarineau avatar laravel-shift avatar markcameron avatar wunc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

media's Issues

Composer throws warning: Ambiguous class resolution.

When running composer update, the latest version of Composer now throws a warning:

Warning: Ambiguous class resolution, "CreateMediaTable" was found in both "$baseDir . '/database/migrations/2014_11_11_110645_create_media_table.php" and "/var/www/oar/vendor/devfactory/media/src/migrations/2014_11_11_110645_create_media_table.php", the first will be used.
Warning: Ambiguous class resolution, "UpdateNameAltTitleInMediaTable" was found in both "$baseDir . '/database/migrations/2015_03_26_135428_update_name_alt_title_in_media_table.php" and "/var/www/oar/vendor/devfactory/media/src/migrations/2015_03_26_135428_update_name_alt_title_in_media_table.php", the first will be used.

Code mess

    public function deleteMedia($group = null)
    {
        $media = $this->getMedia($group);

        $count = 0;
        foreach($media as $item)
        {
            $count += $this->removeMedia($item); //method removeMedia return null (void);
        }

        return $count;
    }

It works just cause of pure accident )

You should rewrite it by something like:

$count ++;
if($this->removeMedia($item)) $count++;

and return bool from removeMedia() method;

Bugs in file models/Media

this is what u need:

  public function getUrlAttribute() {
    return Illuminate\Support\Facades\URL::asset(\Config::get('media.config.files_directory') . $this->filename);
  }

and this is what u got:

  public function getUrlAttribute() {
    return \Url::asset(\Config::get('media::files_directory') . $this->filename);
  }

I do not have \Url class, and u do not publish config with name "media" but with name "media.config"

*I use lara 5.1

Temp Solution for those who got this bug to:

  1. class YourModelMedia extends Devfactory\Media\Models\Media
  2. put following method in it:
    public function getUrlAttribute() {
        return Illuminate\Support\Facades\URL::asset(Illuminate\Support\Facades\Config::get('media.config.files_directory') . $this->filename);
    }
  1. add method media() to model using trait MediaTrait:
    public function media() {
        return $this->morphMany(YourModelMedia::class, 'mediable');
    }

Migration broken in sqlite

The 2015_03_26_135428_update_name_alt_title_in_media_table migration would be boken in sqlite
because sql query is not supported.

Line 17~19

I think using doctrine/dbal and update code be made compatible with other databases

Schema::table('media', function(Blueprint $table) {
      $table->string('name')->nullable()->change();
      $table->string('alt')->nullable()->change();
      $table->string('title')->nullable()->change();
});

Suggestion for new renaming method

Could u please to add simple md5() renaming without part of original name?
And it will be nice to store files to subdirectories in this case, like /public/de/ad/be/ef/12/bb/ce/ed/deadbeef12bbceed.jpg for example.

Get filename trouble

I think you should to add method ->getPath(), instead of using something like this:

File::delete($this->public_path . $this->files_directory . $media->filename);

Ok, i got collection of media by $model->getMedia('group');
Ok, i got an item by this code:

//i use first() but this is a single item. there's no any other files in this group for my model
$model->getMedia('group')->first();

So, how can i get full path to use in Form::image() ?
Should i always construct path manually by $this->public_path . $this->files_directory . $media->filename? This is ridiculous, imho. Don't u think so?

removeMedia function can not operate

$this->public_path, $this->files_directory variable can not be found.

As a temporary solution

private function removeMedia($media) {

$this->public_path = rtrim(config('media.config.public_path'), '/') . '/';
$this->files_directory = rtrim(ltrim(config('media.config.files_directory'), '/'), '/') . '/';

  File::delete($this->public_path . $this->files_directory . $media->filename);
  $media->delete();

}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.