ImageBrowser with images from database

12 posts, 1 answers
  1. Jan Erik
    Jan Erik avatar
    24 posts
    Member since:
    Mar 2011

    Posted 29 Jul 2013 Link to this post

    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
  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 31 Jul 2013 Link to this post

    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!
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Jan Erik
    Jan Erik avatar
    24 posts
    Member since:
    Mar 2011

    Posted 05 Aug 2013 Link to this post

    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
  5. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 06 Aug 2013 Link to this post

    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!
  6. Jan Erik
    Jan Erik avatar
    24 posts
    Member since:
    Mar 2011

    Posted 06 Aug 2013 Link to this post

    From what I can see the folder is removed from the imagebrowser before the controller method is even called. 
  7. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 06 Aug 2013 Link to this post

    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!
  8. Jan Erik
    Jan Erik avatar
    24 posts
    Member since:
    Mar 2011

    Posted 08 Aug 2013 Link to this post

    Are there any plans to change this so it is possible to prevent users from deleting a folder if for instance it contains images?
  9. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 09 Aug 2013 Link to this post

    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!
  10. Jan Erik
    Jan Erik avatar
    24 posts
    Member since:
    Mar 2011

    Posted 14 Aug 2013 Link to this post

    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

  11. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 14 Aug 2013 Link to this post

    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!
  12. Answer
    Jan Erik
    Jan Erik avatar
    24 posts
    Member since:
    Mar 2011

    Posted 22 Aug 2013 Link to this post

    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.
  13. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 26 Aug 2013 Link to this post

    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!
Back to Top
UI for ASP.NET MVC is VS 2017 Ready