Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

colorbox problem when reading image from database

I'm developing a project using asp.net mvc. And i am saving images to database as byte array. Every thing works properly until when iam using colorbox.

I try to using colorbox to show set of product images. when i am click to button i am getting weird result. I am expecting image but its gathering huge amount of weird symbols like below.

<�<�="=a=�=�> >`>�>�?!?a?�?�@#@d@�@�A)AjA�A�B0BrB�B�C:C}C�DDGD�D�EEUE�E�F"FgF�F�G5G{G�HHKH�H�IIcI�I�J7J}J�KKSK�K�L*LrL�MMJM�M�N%NnN�OOIO�O�P'PqP�QQPQ�Q�R1R|R�SS_S�S�TBT�T�U(UuU�VV\V�V�WDW�W�X/X}X�YYiY�ZZVZ�Z�[E[�[�\5\�

Iam sure that works properly including colorbox. Problem occurs when colorbox tries ta get image from database. Any ideas?

Thanks in advance

public FileContentResult Index(int id)
    {
        var media = _entities.Images.AsQueryable()
            .Where(e => e.Id == id)
            .Select(e => e).FirstOrDefault();
        return File(media.ImageData, media.ImageMimeType);
    }

this is hove i get the image.

http://localhost:2632/assets/index/105

this is the pattern of url. for getting image.

$("a[rel=" + "'" + 48 + "']").colorbox({ transition: "fade", title: true, current: true });

this is how i call color box.

<a style=" display:none;" rel="48" href="assets/index/107">asd</a>

this is the how i embed the element to page.

like image 921
beratuslu Avatar asked Apr 16 '11 18:04

beratuslu


1 Answers

Solution available at Problem while working with Jquery colorbox and dynamic images that reading via Aspx

Use colorbox's photo property. Example:

$('a.example').colorbox({photo:true});

The reason is that colorbox's regex to auto-detect image URLs is going to fail for that kind of URL (doesn't contain an image-type extension).

like image 93
tortuga Avatar answered Oct 16 '22 02:10

tortuga