anvc / scalar

Born-digital, open source, media-rich scholarly publishing that’s as easy as blogging.
Other
231 stars 73 forks source link

Uploaded media not available in UI #68

Closed aaron-collier closed 7 years ago

aaron-collier commented 7 years ago

I've uploaded a couple of images to include in a book, they exist on the file system in the books media folder, but the "choose and image" list is empty, etc.

is there a config or permission that I'm missing?

craigdietrich commented 7 years ago

Hi!

Do you mean, the choose an image pulldown for choosing a key image or background image?

Those pulldowns determine what is an image in a rather strict way, the file extension of the uploaded files need to be .jpeg, .jpg, .gif, or .png. So, if your images don't have one of these extensions, or don't have any extension (which can happen on a mac), then they won't show up in the list.

Curious if this helps?

aaron-collier commented 7 years ago

My book is called "test" and this is my media folder:

total 80K
drwxrwxr-x 2 apache www    4.0K May 10 15:37 .
drwxrwxr-x 3 apache www    4.0K May 10 15:15 ..
-rwxrwxr-x 1 apache apache  22K May 10 15:37 book_thumbnail.png
-rwxrwxr-x 1 apache apache  22K May 10 15:36 scholarworks.png
-rwxrwxr-x 1 apache apache  22K May 10 15:36 scholarworks_thumb.png
[root@ip-172-31-21-86 html]# 

So not sure why they aren't loading.

aaron-collier commented 7 years ago

FYI - When I "Import Local Media File" - the upload works, the file shows up on the filesystem, but the UI doesn't indicate any success or failure, it just stays on the import page. So maybe something related to this is the problem?

craigdietrich commented 7 years ago

Ah, so when you try to upload a file, the upload page doesn't refresh to a new page that shows the image, once the upload is complete?

When you go to Dashboard > Media tab, do you see anything listed there?

What Scalar install are you using? One of ours (e.g., scalar.usc.edu) or a custom install?

aaron-collier commented 7 years ago

Right.

This is a fresh install from git master.

craigdietrich commented 7 years ago

When you go to Dashboard > Media tab, do you see anything listed there?

aaron-collier commented 7 years ago

Nope.

craigdietrich commented 7 years ago

Are you familiar with the Web Inspector in your browser? If so, could you open it up and click on the Console tab? This will reveal the ajax request to the server (that comes back after the file is physically uploaded), in which case can you check to see what is returned and if there's any javascript or php error in there?

If the above is out of your league I can try to cook up a lighter weight option.

Either way there's probably a PHP error being thrown for some reason by your server, probably to do with permissions or something.

aaron-collier commented 7 years ago

The validation javascript is certainly failing. Getting a null result. The apache user is the owner of the file system structure, so not sure why a permissions issue would be a problem unless it's doing something outside of the app filesystem structure.

craigdietrich commented 7 years ago

Are you able to open up the request itself (might be under the Net tab)? If so, under the "Response", you should see something, maybe some PHP errors? Or, is the Response itself just blank?

If the response itself is blank, you can open up codeigniter.php in the root folder and switch "production" to "development" and try again: this should turn on errors.

aaron-collier commented 7 years ago

Ah, thanks... getting somewhere. I have this error:

PHP Fatal error:  Uncaught Error: Call to undefined function imagecreatefrompng() in /var/www/html/system/application/libraries/File_Upload.php:139\nStack trace:\n#0 /var/www/html/system/application/libraries/File_Upload.php(43): File_Upload->resize('/var/www/html/t...', 200)\n#1 /var/www/html/system/application/controllers/book.php(541): File_Upload->createMediaThumb('test/', 'media/scholarwo...', 509)\n#2 /var/www/html/system/application/controllers/book.php(167): Book->upload()\n#3 /var/www/html/system/core/CodeIgniter.php(326): Book->_remap('test', Array)\n#4 /var/www/html/codeigniter.php(203): require_once('/var/www/html/s...')\n#5 {main}\n  thrown in /var/www/html/system/application/libraries/File_Upload.php on line 139, referer: http://scalar.calstate.edu/test/upload
craigdietrich commented 7 years ago

Ah! That's it!

Do you have access to PHP on your server? The GD Library needs to be turned on http://php.net/manual/en/book.image.php

I think thumbnail creation is the only operation that uses GD (though there's a few places that thumbnails are made).. if you can't get GD turned on I could put in the pipeline some hooks for Scalar to test whether those functions exist before trying to use them, which would remove those errors.

aaron-collier commented 7 years ago

FIXED!

Thanks! Was that in the docs? I missed it. That should probably be highlighted.

Thanks again!

craigdietrich commented 7 years ago

Great idea, done! https://github.com/anvc/scalar/commit/01e291da5638b2842a7f32d8ef1ab7d87651c38d

Thanks for sticking with it!