RDN-1189
1

Image Insert Forum Message

Scott on 9/20/2015 8:44 PM

Scott on 1/11/2016 6:13 AM

%
(hrs)
Logged

0 (hrs)


 Description

It seems when we upgraded tinymce, we lost the ability to upload images.  We need to add the ability to upload images back to tinymce for only the forum.

Please review this example, as it shows the example to upload a image again: http://www.tinymce.com/tryit/basic.php

Locations we need to make sure the photo can be uploaded:

  1. League > Forum > Add New Post
  2. League > Forum > Click on a thread > Reply to Post
  3. League > Forum > Click on a thread > Quote a Post
  4. League > Forum > Click on a thread > Edit a Post

As you can see from the QuotePost.cshtml page, the javascript logic to complete this is already implemented.  Look for UploadFileUrl.  It points to the ForumController > PostImageUpload.

Please make sure inserting an image works again within those 4 locations of the tinymce editor.  No other place should be allowed to upload a image on the tiny mce editor.

 

Good afternoon Scott,

I was directed to you regarding adding photos into RDNation forum posts. It seems we no longer have those options - just an add/edit video? 

Skip Navigation Links
 

Icatalin Saturday, January 09, 2016 5:23 PM #

Done hope it is correct

 

Scott Saturday, January 09, 2016 1:50 AM #

We don't support old browsers, so thats fine with me.

Good job.  Create a pull request?  Can you create a pull request when you change the status to committed?

 

Icatalin Wednesday, January 06, 2016 8:31 PM #

That iframe was target for the form useded to upload the file,

Now I have modified this to use AJAX. But the "problem" with this is that it works only on browsers that support HTML5 and FormData to get a better idea of this problem take a look on this http://caniuse.com/#search=FormData (Most of the browsers support FormData)  

In other words if you have a client that uses IE9 this will not work.

 

Scott Tuesday, January 05, 2016 3:57 AM #

okay thanks.

I hate iFrames..  Is there any other way to get this done without using an iFrame?

Also, this seems really hacky to me.  Any other way to do this?

curContext.Response.Output.Write("<script>alert('Invalid image file');</script>");
 

Icatalin Sunday, January 03, 2016 10:17 AM #

Yes,

https://bitbucket.org/rdnation/rdnation/branch/RDN-1189-Image-Insert-Forum-Message

https://bitbucket.org/rdnation/rdnation/commits/28da69e8312f800c7cc4d50ec710f93181d522ab?at=dev

Fetch your local repository, maybe is not up to date.

 

Scott Sunday, January 03, 2016 12:58 AM #

I don't see this commit in the source control.

Have you pushed this?

 

Scott Thursday, December 31, 2015 5:24 PM #

So when you include those in the form, the form doesn't post correctly?

Alright, if you need to accomplish this another way, like passing two parameters in via a query string, please do it.  You don't have to pass the model in.  Lets just get it working.

 

Icatalin Wednesday, December 30, 2015 6:25 PM #

Based on your example I have a form which I use to upload the file (image) to server using public ActionResult PostImageUpload(NewPost model)

my form is like

<form id="my_form" action="/forum/postimageupload" target="form_target" method="post" enctype="multipart/form-data" style="width:0px;height:0;overflow:hidden">
        <input id="my_file" name="File" type="file" onchange="$('#my_form').submit();">
        @Html.HiddenFor(x => x.ForumId)    /// Problem Here
        @Html.HiddenFor(x => x.ForumType)  /// Problem Here
    </form>

the problem is that I also need to submit ForumId and ForumType ( I need them in PostImageUpload) and if those 2 lines are pressent then the PostImageUpload will not get called, if I remove those 2 and I have only 

<form id="my_form" action="/forum/postimageupload" target="form_target" method="post" enctype="multipart/form-data" style="width:0px;height:0;overflow:hidden">
        <input id="my_file" name="File" type="file" onchange="$('#my_form').submit();">
    </form>

is working ok (PostImageUpload is called and model.File contains the correct file)

Do you have any idea how can I solve this?

 

Scott Sunday, December 20, 2015 6:03 PM #

Hey, It seems you got the internet images working, but we need to add Image Upload too from the local computer.

Please review this link:

https://pixabay.com/en/blog/posts/direct-image-uploads-in-tinymce-4-42/

You will need to use the following method when uploading an image: RDN.League/ForumController.PostImageUpload

You are welcome to update the method, but you NEED to use the following: DocumentRepository.UploadLeagueDocument to upload the document.

 

Scott Tuesday, December 15, 2015 7:47 PM #

Yes, it seems like your Configurations might not be updated.

Run this on your database. OR just make sure that in this table, there is a value called DEFAULT_RDN_FORUM_ID

INSERT [dbo].[CS_Site_Configuration] ([ID], [Key], [Value], [Description], [Created], [LastModified], [IsRemoved]) VALUES (62, N'DEFAULT_RDN_FORUM_ID', N'8059734d-511c-4511-8770-ee595c10bef5', N'DEFAULT_RDN_FORUM_ID', CAST(0x0000A5340113B482 AS DateTime), NULL, 0)
GO

This SQL was pulled from RDN.League/App_Data/SiteConfigurationData.sql

 

Icatalin Tuesday, December 15, 2015 5:56 PM #

I have entered a correct url like:

http://localhost:1094/forum/post/view/b1fffe079ee247788b201aea925af55e/10149/sub1

but I get an error on this line if (new Guid(forumId) != LibraryConfig.DEFAULT_RDN_FORUM_ID) because it doesn't find "DEFAULT_RDN_FORUM_ID" key in Configurations.

Have any a idea maybe I am missing something?

 

Scott Wednesday, December 09, 2015 6:42 PM #

Be careful here.  If you click any of the tabs or scroll down to retrieve new posts, you might be calling the Production URL.

So: http://localhost:1094/forum/post/view/b1fffe079ee247788b201aea925af55e/10148/test-upload-img for example 

might be turned into http://league.rdnation.com/forum/post/view/b1fffe079ee247788b201aea925af55e/10148/test-upload-img

You might need to make sure its not calling the production url.

 

Icatalin Wednesday, December 09, 2015 4:27 PM #

Hi, I have added the button that allows to upload an image, but I have discovered a problem. (When I try to test step 2.)

On http://localhost:1094/forum/posts/league/b1fffe079ee247788b201aea925af55e I see the list of forums. If I press the link (name) of a forum I have to go to 

http://localhost:1094/forum/post/view/b1fffe079ee247788b201aea925af55e/10148/test-upload-img for example .

the problem is that this last link is supposed to be handled (from Global.asax.cs) by a Post action

            routes.MapRoute(
"ForumViewPost", // Route name
"forum/post/view/{forumId}/{topicId}/{title}", // URL with parameters
new { controller = "Forum", action = "Post", title = UrlParameter.Optional } // Parameter defaults
);

But in the Forum Controller there isn't one. There is a Posts that seems to be a right match.

What should I do? Is this Posts actually the Post method?

 

Scott Saturday, December 05, 2015 3:01 AM #

Catalin, can you try to work on this one?

 

Scott Sunday, October 25, 2015 4:12 AM #

http://www.spoiledtechie.com/post/2013/11/23/TinyMCE-writer-Image-Upload-for-C-MVC.aspx


Powered by BugNET 1.6.339.0