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.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With