public function onVichUploaderPostUpload(Event $event)
    {
        $object = $event->getObject();
        $mapping = $event->getMapping();

        $absoluteDir = $mapping->getUploadDestination().'/'.$mapping->getUploadDir($object);
        $relativeDir = substr_replace($absoluteDir, '', 0, strlen($this->projectDir) + 1);

        $object->setRelativeDir($relativeDir);

        if (false !== strpos($object->getMimeType(), 'image/')) {
            $img = $mapping->getUploadDestination().'/'.$mapping->getUploadDir($object).'/'.$object->getMedia();
            $palette = Palette::fromFilename($img, Color::fromHexToInt('#FFFFFF'));
            $extractor = new ColorExtractor($palette);
            $colors = $extractor->extract();
            $object->setMainColor(Color::fromIntToHex($colors[0]));

            $this->generateCache('/'.$relativeDir.'/'.$object->getMedia());
        }
    }
public function onVichUploaderPostUpload(Event $event)
    {
        $object = $event->getObject();
        $mapping = $event->getMapping();

        $absoluteDir = $mapping->getUploadDestination().'/'.$mapping->getUploadDir($object);
        $relativeDir = substr_replace($absoluteDir, '', 0, strlen($this->projectDir) + 1);

        $object->setRelativeDir($relativeDir);

        if (false !== strpos($object->getMimeType(), 'image/')) {
            $img = $mapping->getUploadDestination().'/'.$mapping->getUploadDir($object).'/'.$object->getMedia();
            $palette = Palette::fromFilename($img, Color::fromHexToInt('#FFFFFF'));
            $extractor = new ColorExtractor($palette);
            $colors = $extractor->extract();
            $object->setMainColor(Color::fromIntToHex($colors[0]));

            $this->generateCache('/'.$relativeDir.'/'.$object->getMedia());
        }
    }
public function onVichUploaderPostUpload ( Event $ event ) { $ object = $ event -> getObject ( ) ; $ mapping = $ event -> getMapping ( ) ; $ absoluteDir = $ mapping -> getUploadDestination ( ) . '/' . $ mapping -> getUploadDir ( $ object ) ; $ relativeDir = substr_replace ( $ absoluteDir , '' , 0 , strlen ( $ this -> projectDir ) + 1 ) ; $ object -> setRelativeDir ( $ relativeDir ) ; if ( false !== strpos ( $ object -> getMimeType ( ) , 'image/' ) ) { $ img = $ mapping -> getUploadDestination ( ) . '/' . $ mapping -> getUploadDir ( $ object ) . '/' . $ object -> getMedia ( ) ; $ palette = Palette :: fromFilename ( $ img , Color :: fromHexToInt ( '#FFFFFF' ) ) ; $ extractor = new ColorExtractor ( $ palette ) ; $ colors = $ extractor -> extract ( ) ; $ object -> setMainColor ( Color :: fromIntToHex ( $ colors [ 0 ] ) ) ; $ this -> generateCache ( '/' . $ relativeDir . '/' . $ object -> getMedia ( ) ) ; } }
Update RelativeDir.
Update RelativeDir .