problem with media settings -Pictures are stored into...

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 years ago
I uploaded many pictures before realizing they are stored in database by default in the [dbo].[Picture] table, and now I just changed the setting "Pictures to be stored on" from database to File System.  But  now all of pictures superseded with default image (No Image Available). How to Resolve this problem.
Now pictures path is  mydomain/content/images/thumbs/default-image.gif
7 years ago
When setting is on:  Pictures are stored into...   database, Images are displayed well like this:
<img alt="media.product.imagealternatetextformat.details"
src="http://hiweb.com/content/images/thumbs/0001667_-_300.jpeg" title="" itemprop="image" id="main-product-img-491">



But when I change setting to Pictures are stored into...   file system, All images are replaced with the default image:
<img alt="media.product.imagealternatetextformat.details"
src="http://hiweb.com/content/images/thumbs/default-image_300.gif"  title="" itemprop="image" id="main-product-img-491">
7 years ago
Nobody can help?
6 years ago
im noticing this is a common thing.
very important issues like this dont get the attention they deserve..

I'm starting to take over them one by one.

I'm currently testing workarounds and fixes for this issue.

I dont work for nop but i sincerely wanna help
6 years ago
To change this behavior, you could modify PictureService.GetPictureUrl -

    public virtual string GetPictureUrl(Picture picture, 
            int targetSize = 0,
            bool showDefaultPicture = true,
            string storeLocation = null,
            PictureType defaultPictureType = PictureType.Entity)
        {
            string url = string.Empty;
            byte[] pictureBinary = null;
            if (picture != null)
                pictureBinary = LoadPictureBinary(picture);
            if (picture == null || pictureBinary == null || pictureBinary.Length == 0)
            {
                //**add customization to retrieve the Url for the picture in question here**//
                if(showDefaultPicture)
                {
                    url = GetDefaultPictureUrl(targetSize, defaultPictureType, storeLocation);
                }
                return url;
            }
....
6 years ago
Sorry to bump an old thread, but the solution in this thread might be relevant in my situation.

Adam,

Would your code change help us if say our store setting is set to store images in DB. If we change it to File system, images won't be broken and we won't need to re-upload all product photos again into file?

3.8

Thanks
6 years ago
Edit: not sure why forum double posted.
6 years ago
Vuffy wrote:
Sorry to bump an old thread, but the solution in this thread might be relevant in my situation.

Adam,

Would your code change help us if say our store setting is set to store images in DB. If we change it to File system, images won't be broken and we won't need to re-upload all product photos again into file?

3.8

Thanks


Yep, the reason it's failing is shown in the code snippet I posted. PictureBinary will be NULL unless StoreInDb is enabled.  As you can see, if PictureBinary is NULL, the "default picture url" is returned.


Example flow (based on naming convention) might look like:

check if proper file exists:
{PictureId}_{thumbSize}.png

Doesn't exist?  Find original (created on upload)
{PictureId}.png

Resize and create new image on file system called:
{PictureId}_{thumbSize}.png

Hope that helps!
6 years ago
Vuffy wrote:
Sorry to bump an old thread, but the solution in this thread might be relevant in my situation.

Adam,

Would your code change help us if say our store setting is set to store images in DB. If we change it to File system, images won't be broken and we won't need to re-upload all product photos again into file?

3.8

Thanks


I should also mention, there's no "code change," I'm just listing the code where customization to allow for this would occur.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.