Skip to content

Cannot display store logo in order PDF invoice to path error #667

@TheFlo

Description

@TheFlo

Hi GrandNode Team,

While downloading order PDF invoices, I noticed the logo was not displayed despite having a logo uploaded.

Further investigation shows that the logo URL starts with a "/", resulting in an invisible logo.

In PictureService.GetThumbUrl, line 162, there is a call to _mediaFileStore.Combine, using the store location URL as first parameter:

protected virtual string GetThumbUrl(string thumbFileName, string storeLocation = null)
{
storeLocation = !string.IsNullOrEmpty(storeLocation) ? storeLocation : "";
return _mediaFileStore.Combine(storeLocation, ImageThumbPath, thumbFileName);
}

In IFileStoreExtensions.Combine, line 177, a "/" is added before the combined path if the path is not rooted, which works for local path but not for absolute url path:

var combined = string.Join("/", normalizedParts);
if (!Path.IsPathRooted(combined)) combined = "/" + combined;
return combined;
}

There is only one single call to IFileStoreExtensions.Combine using an absolute URL as first parameter, so updating PictureService.GetThumbUrl might be the best place to fix the bug. This worked for me:

    protected virtual string GetThumbUrl(string thumbFileName, string storeLocation = null)
    {
        storeLocation = !string.IsNullOrEmpty(storeLocation) ? storeLocation : string.Empty;
        return storeLocation.TrimEnd('/') + _mediaFileStore.Combine(ImageThumbPath, thumbFileName);
    }

Do you see a better solution in order to fix this issue ?

Kind regards

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions