Coder Social home page Coder Social logo

Comments (4)

davarresc avatar davarresc commented on September 13, 2024

The GalleryBehavior class has been refactorized and createFolders method has a bug. Due to the normalizePath method, the createDirectory method understands the file name as a folder and create the folders with the 'file/to/path/image.jpg' path instead of 'file/to/path'.

If you override createFolders method from GalleryBehavior class, it works fine. For example:

class GalleryBehavior extends \zxbodya\yii2\galleryManager\GalleryBehavior
{

    private function createFolders($filePath)
    {
        return FileHelper::createDirectory(FileHelper::normalizePath(dirname($filePath)), 0777);
    }

    /**
     * Replace existing image by specified file
     *
     * @param $imageId
     * @param $path
     */
    public function replaceImage($imageId, $path)
    {
        $this->createFolders($this->getFilePath($imageId, 'original'));

        $originalImage = Image::getImagine()->open($path);
        //save image in original size

        //create image preview for gallery manager
        foreach ($this->versions as $version => $fn) {
            /** @var ImageInterface $image */

            $image = call_user_func($fn, $originalImage);
            if (is_array($image)) {
                list($image, $options) = $image;
            } else {
                $options = [];
            }

            $image
                ->save($this->getFilePath($imageId, $version), $options);
        }
    }
}

from yii2-gallery-manager.

zxbodya avatar zxbodya commented on September 13, 2024

Hi,
@davarresc thanks for checking this - indeed there was PR merged recently, changing this method #62

can you create pr with your fix?

from yii2-gallery-manager.

davarresc avatar davarresc commented on September 13, 2024

Hi,
Yes of course, I just did the PR.
Regards.

from yii2-gallery-manager.

zxbodya avatar zxbodya commented on September 13, 2024

thanks, merged it 👍
@amismailz can you check is it fixed you issue?

from yii2-gallery-manager.

Related Issues (20)

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.