OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Uploaded image URLs broken using TinyMCE interface

Are you responsible for making OJS work -- installing, upgrading, migrating or troubleshooting? Do you think you've found a bug? Post in this forum.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
What to do if you have a technical problem with OJS:

1. Search the forum. You can do this from the Advanced Search Page or from our Google Custom Search, which will search the entire PKP site. If you are encountering an error, we especially recommend searching the forum for said error.

2. Check the FAQ to see if your question or error has already been resolved.

3. Post a question, but please, only after trying the above two solutions. If it's a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a development question, try the OJS Development subforum.

Uploaded image URLs broken using TinyMCE interface

Postby dbrannen » Fri Oct 18, 2013 8:52 am

Hi,
We're running OJS 2.4.2.0 and have issues with images uploaded via tiny MCE. When
we upload an image, the image is sucessfully uploaded but the url is missing the
host component (or has an additional http:// component)

Ie, after uploading and image called raptor.jpg, a broken image icon appears in the
content box with the following html

<p><img src="http://public/site/images/admin/raptor2.jpg" alt="" data-mce-src="http://public/site/images/admin/raptor2.jpg"></p>

We either need it not to have the http:// prefix and just have an initial / (Preferable) or have the hostname component embedded
after http://

I had a play with some of the basedir settings within the tinyMCE plugin but didn't get anywhere resolving this.

I've attached a word document with screen-shots in case it helps explain what we're doing.

Any suggestions gratefully received.

Thanks,
Duncan
Attachments
Upload images in TinyMCE interface - ERROR.docx
(551.66 KiB) Downloaded 39 times
dbrannen
 
Posts: 7
Joined: Wed Sep 25, 2013 12:55 pm

Re: Uploaded image URLs broken using TinyMCE interface

Postby rootl » Mon Oct 21, 2013 7:07 am

Greetings Duncan,

We encountered nearly the same problem.

We did 2 things in the ojs config file that fixed the problem:

1) In line 33 of the ojs config.inc.php file, the base url must include a trailing forward slash (/) at the end.
ie: base_url[index] = "http://yourojsinstallation.com/"

2) line 197 of the ojs config.inc.php file, "public_files_dir" must include a forward slash before the directory name.
ie: public_files_dir = /public

We are running Apache 2.2 on a Windows 2008 server. I don't know if our solution works on Linux/Unix .

I hope this at least gets you in the right direction! Good luck,

Leah
rootl
 
Posts: 62
Joined: Wed Feb 20, 2013 7:17 am

Re: Uploaded image URLs broken using TinyMCE interface

Postby dbrannen » Mon Oct 21, 2013 8:17 am

Thanks Leah,
You're a star :)

We're on Debian, already had the trailing / on the base_url but nothing on the public_files_dir

Now using public_files_dir = /public

and it's all fine.

Cheers,
Duncan
dbrannen
 
Posts: 7
Joined: Wed Sep 25, 2013 12:55 pm

Re: Uploaded image URLs broken using TinyMCE interface

Postby rootl » Wed Oct 23, 2013 5:43 am

No problem! Happy to help - usually I am asking more questions than offering solutions :)

I think we should request to have additional wording on the OJS config file, because apparently these problems affect Linux *and* Windows servers.
rootl
 
Posts: 62
Joined: Wed Feb 20, 2013 7:17 am

Re: Uploaded image URLs broken using TinyMCE interface

Postby dbrannen » Mon Oct 28, 2013 8:55 am

Hi All,
This fix has had a knock-on effect of breaking uploads elsewhere. Users now can't upload images as headers
in the journals but receive an error message as the server is now trying to write to /public in the root filesystem. Apache Logs show

[Mon Oct 28 15:42:39 2013] [error] [client 138.251.61.67] ojs2 has produced an error\n Message: WARNING: move_uploaded_file(): Unable to move '/tmp/phpEk9g7a' to '/public/journals/2/homeHeaderTitleImage_en_US.jpg'\n In file: /var/www/lib/pkp/classes/file/FileManager.inc.php\n At line: 111\n Stacktrace: \n Server info:\n OS: Linux\n PHP Version: 5.3.3-7+squeeze15\n Apache Version: Apache/2.2.16 (Debian)\n DB Driver: mysql\n DB server version: 5.1.66-0+squeeze1, referer: http://ojs-test.st-andrews.ac.uk/index. ... aveSetup/5

I've linked /public to /var/www/public which has resolved this but I'm guessing this isn't how it should work. I'd think if there was an incompatibility between
how tincyMCE generated URLs and how Filemanager generated paths others would be seeing it.

Any other suggestions as to what is amiss with our setup?

Cheers,
Duncan
dbrannen
 
Posts: 7
Joined: Wed Sep 25, 2013 12:55 pm

Re: Uploaded image URLs broken using TinyMCE interface

Postby asmecher » Mon Oct 28, 2013 9:05 am

HI Duncan,

What is the value of the public_files_dir setting in your config.inc.php file? It should generally be the default:
Code: Select all
public_files_dir = public


[Edit: I see it's listed above as /public; that's the problem.]

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8470
Joined: Wed Aug 10, 2005 12:56 pm

Re: Uploaded image URLs broken using TinyMCE interface

Postby rootl » Mon Oct 28, 2013 10:32 am

Hi Duncan and Alec,

We are not having a problem with all uploads, but with Announcements. We reverted to public_files_dir = public,

and still no resolution for uploading images in the Announcements area only.


We noticed that Announcements uses a different method of uploading images than Static Pages plugin or "The Look" area, and traced to this file:

\lib\pkp\lib\tinymce\jscripts\tiny_mce\plugins\jbimages\integratePKP.php

In our case, the uploaded images are actually uploaded, but the entire pathname is not saved, so the image appears broken.
rootl
 
Posts: 62
Joined: Wed Feb 20, 2013 7:17 am

Re: Uploaded image URLs broken using TinyMCE interface

Postby MichaelThessel » Mon Oct 28, 2013 7:33 pm

Hi Rootl,

Could you please post your config.inc.php (except credentials!) and an example of the image urls this configuration is creating? Could you please also send me the full file system path where you store your images?

Thanks,

Michael
MichaelThessel
 
Posts: 10
Joined: Fri Mar 22, 2013 9:56 am

Re: Uploaded image URLs broken using TinyMCE interface

Postby dbrannen » Wed Oct 30, 2013 4:24 am

Hi Alec,
Any thoughts on the original issue of the TInyMCE URLs without the initial / it generates urls
like

http://public/site/images/admin/raptor2.jpg

for uploaded files.

Cheers,
Duncan


asmecher wrote:HI Duncan,

What is the value of the public_files_dir setting in your config.inc.php file? It should generally be the default:
Code: Select all
public_files_dir = public


[Edit: I see it's listed above as /public; that's the problem.]

Regards,
Alec Smecher
Public Knowledge Project Team
dbrannen
 
Posts: 7
Joined: Wed Sep 25, 2013 12:55 pm

Re: Uploaded image URLs broken using TinyMCE interface

Postby MichaelThessel » Wed Oct 30, 2013 12:15 pm

Hi Duncan,

What is the publicly accessible directory you want to link to and what is your public_files_dir setting? One thing to note is that TinyMCE caches its settings and it might be necessary to delete all the .gz files in the cache directory to make TinyMCE aware of the public_files_dir change.

Cheers,

Michael
MichaelThessel
 
Posts: 10
Joined: Fri Mar 22, 2013 9:56 am

Re: Uploaded image URLs broken using TinyMCE interface

Postby dbrannen » Fri Nov 08, 2013 6:01 am

Hi Michael,
Sorry for the slow reply.

My public_files_dir was

public_files_dir = public

but is currently

public_files_dir = /public

If I have it set to public and upload a file (raptor2.jpg) via TinyMCE, it uploads the file correctly to the public folder but generates an absolute URL with no host component.

eg <img src="http://public/site/images/admin/raptor2.jpg

If I set it to /public, the correct URL is is generated <img src="http://ojs.st-andrews.ac.uk/public/site/images/admin/raptor2.jpg

Cheers,
Duncan
dbrannen
 
Posts: 7
Joined: Wed Sep 25, 2013 12:55 pm

Re: Uploaded image URLs broken using TinyMCE interface

Postby MichaelThessel » Tue Nov 12, 2013 12:48 pm

Hi Duncan,

Could you please set your public_files_dir = public and delete all your *.gz files from your cache directory. TinyMCE caches its settings in a gzip file and by the looks of it it still works of the old settings.

Cheers,

Michael
MichaelThessel
 
Posts: 10
Joined: Fri Mar 22, 2013 9:56 am

Re: Uploaded image URLs broken using TinyMCE interface

Postby dbrannen » Thu Nov 14, 2013 7:34 am

Hi Michael,
That returns me to where I was, uploading an image using tinyMCE shows a broken image and creates URLs of the form

<p><img src="http://public/site/images/admin/raptor7.jpg" alt="" data-mce-src="http://public/site/images/admin/raptor7.jpg"></p>


The image file is correctly uploaded into /var/www/public/site/images/admin

Cheers,
Duncan
dbrannen
 
Posts: 7
Joined: Wed Sep 25, 2013 12:55 pm

Re: Uploaded image URLs broken using TinyMCE interface

Postby MichaelThessel » Mon Nov 18, 2013 1:21 pm

Hi Duncan,

Do you have a trailing slash at the end of your base_url (i.e. base_url = "http://example.com/")? This might cause the behavior you described.

If you test config changes related to TinyMCE image uploads, please do the config change, remove the cache files and re-upload the image.

Cheers,

Michael
MichaelThessel
 
Posts: 10
Joined: Fri Mar 22, 2013 9:56 am

Re: Uploaded image URLs broken using TinyMCE interface

Postby dbrannen » Tue Nov 19, 2013 9:34 am

Hi Michael,
Thanks, that was spot on. Not sure how the slash got there habit I guess.

Cheers,
Duncan
dbrannen
 
Posts: 7
Joined: Wed Sep 25, 2013 12:55 pm


Return to OJS Technical Support

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Yahoo [Bot] and 3 guests