Forum

Thread tagged as: Problem, Redactor, CKEditor

Image uploads in Redactor or CKEditor not appearing in Assets?

Hi all,

I've just had reported that image uploads processed through the Redactor editor were not appearing in the Assets section, which I thought was a little strange, I'm sure it did before.

I've tested both a clean install of the Redactor plugin, and also the CKEditor plugin, and when I upload an image using either in a page, the images do not show in the asset panel within Perch. They do appear in their various resized forms in the asset folder via FTP though!

If I use the default Markdown editor, the image upload appears fine in the Asset panel.

Any ideas what might be causing this?

Thanks

Perch: 2.7.4, PHP: 5.4.35, MySQL: 5.5.40-36.1, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (2.7.4), assets (2.7.4), categories (2.7.4), perch_events (1.9), perch_forms (1.8.2), perch_blog (4.5.4), perch_backup (1.2)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_blog', 'perch_forms', 'perch_events' );
PERCH_LOGINPATH: /control
PERCH_PATH: /home/[...]/public_html/[...]/[...]
PERCH_CORE: /home/[...]/public_html/[...]/[...]/core
PERCH_RESFILEPATH: /home/[...]/public_html/[...]/assets/files
Image manipulation: GD Imagick
PHP limits: Max upload 64M, Max POST 64M, Memory: 256M, Total max file upload: 64M
Resource folder writeable: Yes
DOCUMENT_ROOT: /home/[...]/public_html/[...]
HTTP_HOST: [...]lab.com
REQUEST_URI: /[...]/core/settings/diagnostics/
SCRIPT_NAME: /[...]/core/settings/diagnostics/index.php
Joel Stanford

Joel Stanford 0 points

  • 6 years ago

Also just tried updating to Perch 2.7.7 as I just noticed it was out of date - still no difference made.

An image uploaded in redactor or ckeditor doesn't show in the Assets section, but displays on the page OK and appears in the assets folder on FTP.

Thanks.

Simon Clay

Simon Clay 127 points

Buckets are not built into the Editors yet. As shown in this thread: https://forum.grabaperch.com/forum/09-12-2014-redactor-choose-and-assets

Hmmm, I'm sure images uploaded in the editors previously were added to the assets library automatically (although I can't remember as we switched the client from the Markdown editor to the Redactor editor - we're now waiting to launch the site but this is a show stopper for the client!) - I am aware that you can not browse and insert images from the assets library within the editors, but this is for uploading images which is supported in the editors.

Also previous support threads indicate that images/files uploaded via the editors should appear in the default bucket at least (See - https://forum.grabaperch.com/forum/12-15-2014-textarea-bucket-not-respected-with-redactor ), which isn't happening for me. We don't use custom buckets either, just the default one.

The code seems to be all there to handle the image into the asset library within the editors upload.php, but I've not looked deeply into it and compared it with the MarkItDown upload script yet. So I'm pretty sure this should be happening.

Thanks.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Assets uploaded via one of those editors should be added to the Assets app.

OK, it's definitely not happening.

I've even setup a brand new subdomain, installed a brand new Perch 2.7.7, along with Redactor plugin from the site... and uploading an image via Redactor still doesn't appear in the Assets app.

What is going on?! :(

Right, I've even tested a brand new Perch 2.7.7 install, latest Redactor plugin and latest CKEditor plugin on a completely different server, running a different PHP etc, and it's still doing the same thing.

Any image or file uploaded in Redactor or CKEditor will not appear in the Assets app. It appears on the page fine, and it exists inside the resources directory, but it is not in the Assets app (which is completely empty on the fresh install), and theres no records created in the database for the assets either (in the perch2_resources table).

Perch: 2.7.7, PHP: 5.4.28, MySQL: 5.5.36, with PDO
Server OS: Linux, apache2handler
Installed apps: content (2.7.7), assets (2.7.7), categories (2.7.7)
App runtimes: <?php $apps_list = array( 'content', 'categories', );
PERCH_LOGINPATH: /perch
PERCH_PATH: /home/joel/web/[domain]/public_html/perch
PERCH_CORE: /home/joel/web/[domain]/public_html/perch/core
PERCH_RESFILEPATH: /home/joel/web/[domain]/public_html/perch/resources
Image manipulation: GD Imagick
PHP limits: Max upload 2M, Max POST 8M, Memory: 128M, Total max file upload: 2M
Resource folder writeable: Yes
HTTP_HOST: [domain]
DOCUMENT_ROOT: /home/joel/web/[domain]/public_html
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php

Just in case its useful too, I just noticed that when I upload an image via redactor, I get the following files appear in the resources directory in FTP:

/resources/example-w640.png
/resources/example.png

If, however, I use the Assets app to upload the image, I get the following files appear:

/resources/example-thumb@2x.png
/resources/example.png

I noticed that on the clients install, most images have the original, a w640 version, and a thumb@2x, judging from when image uploads were working correctly.

Is it stalling somehow (strange on different servers too) on creating the thumbnail?

Not sure if it helps, but something noticed anyway.

Thanks.

Drew McLellan

Drew McLellan 2638 points
Perch Support

That could be related. If there's no thumb being generated then it won't show in the Assets panel. I'll take a look into it.

Drew, duplicating the upload script from the markitup editor and changing the response to json, then modifying a few options on the redactor config, works.

If anybody is interested,

  1. copy the markitup/image_upload/image_upload.php file to redactor/perch/upload2.php.
  2. modify the last block of redactor/perch/upload2.php
            if ($is_image) {
                $result = $Assets->get_resize_profile($Asset->id(), $width, $height, ($crop?'1':'0'), false, $density);
                if ($result) {
                    $web_path = $result['web_path'];
                }else{
                    $web_path = $Asset->web_path();  
                }
            }else{
                $web_path = $Asset->web_path();
            }

            echo stripslashes(PerchUtil::json_safe_encode(array(
                'filelink' => $web_path
            ))); 

            exit;
  1. then in your redactor/_config.inc, the redactor setup should be
$(function() {
    $('textarea.redactor').each(function(i,o){
        var self = $(o);
        self.wrap('<div class="editor-wrap" style="float:left;"></div>');

        var inputName =  'miu_image_upload_image',
              uploadPath = 'PERCH_LOGINPATH/addons/plugins/editors/redactor/perch/upload2.php';

        // define height from textarea 'size' attribute
        var height = parseInt(self.css('height')) || 180;

        self.redactor({
            minHeight: height,
            imageUploadParam: inputName,
            fileUploadParam:  inputName,
            imageUpload: uploadPath,
            fileUpload:  uploadPath,
            uploadImageFields: {
                'image'  :  true,
                'width'  :  self.attr('data-width')||'',
                'height' :  self.attr('data-height')||'',
                'crop'   :  self.attr('data-crop')||'',
                'quality':  self.attr('data-quality')||'',
                'sharpen':  self.attr('data-sharpen')||'',
                'density':  self.attr('data-density')||'1',
                'bucket' :  self.attr('data-bucket')||'default'
            },
            uploadFileFields: {
                'image': false,
                'bucket': self.attr('data-bucket')||'default'
            }
        });
    });
});
Matt Bee

Matt Bee 0 points
Registered Developer

I'm experiencing the same as Leigh, the image is being uploaded to the resources directory, but then not displaying in the redactor editor.

There isn't a thumbnail being created, but more importantly nothing is being displayed in the text area.

Any update on that one? Having the same issue with redactor and image insert action.

UPDATE: The same goes for ckeditor!

Any updates--I'm also seeing this problem. I'm using creditor and no images are showing in the assets panel.