This is a migrated thread and some comments may be shown as answers.

ImageBrowser with images from database

11 Answers 615 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Jan Erik
Top achievements
Rank 2
Jan Erik asked on 29 Jul 2013, 12:20 PM
I'm trying to create an implementation of the imagebrowser where the images are read from a database table. 

It reads the images correctly from the database, but they are being treated as folders for some reason. So it never calls the Thumbnail controller method, it just displays the default folder thumbnail. The same thing happens when I try to select an image. It doesn't call the Image method, but instead another call to the Read method.

Any ideas?

I've attached some snippets from my code. We are currently usin gKendoUI 213.1.514.


Regards,
Jan Erik

11 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 31 Jul 2013, 02:12 PM
Hi Jan,

 We created a sample project which implements image browser with a database. Perhaps it would help you implement your requirements.

Regards,
Atanas Korchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Jan Erik
Top achievements
Rank 2
answered on 05 Aug 2013, 07:22 AM
Thank you for this, I got this more or less sorted now. I still have one question/issue though.

If a user tries to delete a folder that contains images I want to stop it with a message to the user. Do you have an example of how to accomplish this?

Thanks in advance.


Regards,
Jan Erik
0
Atanas Korchev
Telerik team
answered on 06 Aug 2013, 07:12 AM
Hi Jan,

 You can try returning http error in this case. Check how the other action methods are implemented.

Regards,
Atanas Korchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Jan Erik
Top achievements
Rank 2
answered on 06 Aug 2013, 11:56 AM
From what I can see the folder is removed from the imagebrowser before the controller method is even called. 
0
Atanas Korchev
Telerik team
answered on 06 Aug 2013, 12:28 PM
Hello Jan,

 You are right. The folder will be remove at the client-side. Currently there is no way to prevent this behavior without modifying the source code of the editor widget.

Regards,
Atanas Korchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Jan Erik
Top achievements
Rank 2
answered on 08 Aug 2013, 11:42 AM
Are there any plans to change this so it is possible to prevent users from deleting a folder if for instance it contains images?
0
Atanas Korchev
Telerik team
answered on 09 Aug 2013, 08:17 AM
Hi Jan,

 I suggest you open a feature request for this in our feedback portal. It would help us track user interest and prioritize it against similar requests.

Regards,
Atanas Korchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Jan Erik
Top achievements
Rank 2
answered on 14 Aug 2013, 08:50 AM
As it is now when you insert an image into the editor it inserts a relativ path to the image/controller. For instance: <img alt="" src="/ImageGallery/Image?path=test1.jpg" />.

Is there a way to get it to insert the full path?


Regards,
Jan Erik

0
Atanas Korchev
Telerik team
answered on 14 Aug 2013, 09:30 AM
Hello Jan,

 The editor doesn't provide any built-in feature for this behavior. You can however process the HTML server side and replace the src attribute with the absolute URL. You can use a regular expression replace to do that.

Regards,
Atanas Korchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Accepted
Jan Erik
Top achievements
Rank 2
answered on 22 Aug 2013, 10:30 AM
There seems to been an error with the ImageBrowser in the latest builds. After updating to 2013.2.819/820 the thumbnail won't display after uploading a new image. 

The controller method Thumbnail is called but the path argument is "undefined". The image is uploaded correctly and the next time I open the ImageBrowser the thumbnail is displayed correctly. 

If I run 2013.2.729 it works fine.
0
Rosen
Telerik team
answered on 26 Aug 2013, 07:26 AM
Hi Jan,

With the latest internal build we have addressed an issue which is workaround in the sample project my colleague has send you.  This workaround is causing the issue you have observed, however as you are using the latest internal build it is no longer required and you should modify the Upload action method to return an instance of ImageBrowserEntry instead of an anonymous object:

public ActionResult Upload(string path, HttpPostedFileBase file)
{
    if (file != null)
    {
        var files = new FilesRepository();
        var parentFolder = files.GetFolderByPath(path);
        if (parentFolder != null)
        {
            files.SaveImage(parentFolder, file);
            return Json(
                new ImageBrowserEntry
                {
                    Name = Path.GetFileName(file.FileName)
                }
            , "text/plain");
        }
    }
    throw new HttpException(404, "File Not Found");
}

Regards,
Rosen
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Editor
Asked by
Jan Erik
Top achievements
Rank 2
Answers by
Atanas Korchev
Telerik team
Jan Erik
Top achievements
Rank 2
Rosen
Telerik team
Share this question
or