Giter VIP home page Giter VIP logo

Comments (18)

andris-sevcenko avatar andris-sevcenko commented on June 16, 2024

What Craft version are you using?

from redactor.

peter-tell avatar peter-tell commented on June 16, 2024

Sorry, that would have been helpful:

Image driver & version | Imagick 3.4.3 (ImageMagick 6.9.6-2)
-- | --
Craft Pro 3.0.7
-- | --
Redactor | 2.0.1

from redactor.

noxify avatar noxify commented on June 16, 2024

I can't reproduce the problem.

  • Craft PRO 3.0.7
  • Redactor 2.0.1

Assets Configuration:

  • Volume: local ( @webroot/uploads)
  • Transformer: Thumb / Small / Medium ( copied from the HappyLager example)

I have tested it with the following:

  • Upload image via Redactor Editor
  • Upload image via Assets page and choose it via the Redactor Editor

Question:

  • If you have no transformer defined, is it working?
  • Are all directory permissions set correctly

from redactor.

peter-tell avatar peter-tell commented on June 16, 2024

Ok thanks @noxify - I'll dig deeper into it and try to get more info.

from redactor.

peter-tell avatar peter-tell commented on June 16, 2024

If you have no transformer defined, is it working?

Yes

Are all directory permissions set correctly

They are. This was working before I updated from Craft 3.0.5 and Redactor 2.0.0.1

For what it's worth, both of these are in Matrix blocks. Not sure if that makes a difference but I'll keep testing to see if I can isolate the problem.

from redactor.

noxify avatar noxify commented on June 16, 2024

I have tested it with an Matrix field - and it's working, too.

bildschirmfoto 2018-05-11 um 15 36 48

from redactor.

noxify avatar noxify commented on June 16, 2024

Maybe you can give it a try with a fresh installation?

from redactor.

peter-tell avatar peter-tell commented on June 16, 2024

Thanks for the help @noxify. I'll keep digging.

from redactor.

peter-tell avatar peter-tell commented on June 16, 2024

Not sure this helps at all, but for some reason it's not getting the full file path for my transformed image, just the filename:

5. in /vendor/craftcms/cms/src/helpers/FileHelper.php at line 260 – yii\helpers\BaseFileHelper::getMimeType('test-file.jpg', null, true)

     /**
     * @inheritdoc
     */
    public static function getMimeType($file, $magicFile = null, $checkExtension = true)
    {
        try {
            $mimeType = parent::getMimeType($file, $magicFile, $checkExtension);
        } catch (\Throwable $e) {
            if (!$checkExtension) {
                throw $e;
            }
            $mimeType = null;
        }

from redactor.

jameskrill avatar jameskrill commented on June 16, 2024

I had this issue just happen. What I figured out in my case, is that the selected image source had a smaller resolution/size than the transform selected, resulting in the file not being found.

Seems like a bug that you could select a transform that doesn't exist... OR... craft should fall back on the next available transform.

For example, if the transform 'full' is 1600px wide, but your source image is 800px, the source image should be served if 'full' is selected as the transform to insert. Or better yet, you shouldn't be able to select that transform when inserting the image.

from redactor.

peter-tell avatar peter-tell commented on June 16, 2024

Thanks @jameskrill -- Unfortunately that's not it in my instance.

I've tracked this down to a change in vendor\craftcms\cms\src\elements\Asset.php on line 708 in either 3.0.6 or 3.0.7

Specifically FileHelper::isGif($this->filename) is causing my problem. If I remove that, the issue is gone.

from redactor.

peter-tell avatar peter-tell commented on June 16, 2024

@andris-sevcenko Not sure it's worth the paper it's printed on, but adding the full path to the image fixed my problem.

I changed line 708 of vendor\craftcms\cms\src\elements\Asset.php

From:

if (FileHelper::isGif($this->filename) && !Craft::$app->getConfig()->getGeneral()->transformGifs) {
            return AssetsHelper::generateUrl($volume, $this);
        }

To:

if (FileHelper::isGif(FileHelper::normalizePath($volume->getRootPath().DIRECTORY_SEPARATOR.$this->getPath())) && !Craft::$app->getConfig()->getGeneral()->transformGifs) {
            return AssetsHelper::generateUrl($volume, $this);
        }

Without being more familiar with the codebase I'm not sure if there are repercussions to this.

from redactor.

noxify avatar noxify commented on June 16, 2024

@page-8 - Is this then not a craftcms/cms issue?

Btw. The path info was removed in this commit:
craftcms/cms@112e2f6#diff-1439c2c7558601e6752050108ba410d4L708

from redactor.

andris-sevcenko avatar andris-sevcenko commented on June 16, 2024

@page-8

Without being more familiar with the codebase I'm not sure if there are repercussions to this.

This will fail for remote Volumes, sadly.

The codeblock you pasted above is there exactly because Craft sometimes needs to decide on the mimetype based just on the filename. It's curious that it's not working for you, though.

Are you, by any chance, overriding or disabling the error handler component in your app configuration? That particular block of code relies on Yii's error handler converting errors to exceptions.

from redactor.

peter-tell avatar peter-tell commented on June 16, 2024

@andris-sevcenko

That's what's really weird about this. The only place the exception is (seemingly) not getting caught is in the Redactor Transform. For example, I'm not getting an error on the Assets Listing page.

Are you, by any chance, overriding or disabling the error handler component in your app configuration?

No, this is the only thing in my general config:

'*' => [
        'defaultWeekStartDay'  => 0,
        'enableCsrfProtection' => true,
        'omitScriptNameInUrls' => true,
        'cpTrigger'            => 'webmaster',
        'securityKey'          => getenv('SECURITY_KEY'),
        'useEmailAsUsername'   => true,
        'allowUpdates'         => false,
        'phpSessionName'       => 'MTMSessId',
        'sendPoweredByHeader'  => false,
    ],

This is happening on my local environment using MAMP 4 and the Arcustech server where we have the site hosted.

This is also happening for me on a fresh installation of Craft 3 with only the Redactor plugin installed and one field type called Body with one Transform called testTransform

Per your comment @noxify , it seems like it's only happening with Redactor's use of this only when it comes to a transform. (as far as I can tell)

from redactor.

andris-sevcenko avatar andris-sevcenko commented on June 16, 2024

Got it, I'll see if I can reproduce!

from redactor.

andris-sevcenko avatar andris-sevcenko commented on June 16, 2024

See the issue, working on a fix

from redactor.

peter-tell avatar peter-tell commented on June 16, 2024

Sweet, thanks @andris-sevcenko !

from redactor.

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.