0

JS

import { LightningElement } from 'lwc';
import Salesforce_Images from '@salesforce/resourceUrl/trailhead_logo';
export default class ImageDisplay extends LightningElement {
  
  salesforceImageUrl = Salesforce_Images;

}

HTML

<template>
    <lightning-card title="Use Static Resource in Lightning Web Component">
        <div class="slds-p-horizontal_small">

            <img src={salesforceImageUrl}>
        </div>
    </lightning-card>
</template>

I have stored image in static resource with name trailhead logo. but image is not appearing.

I have stored image in a zip file, then uploaded to static resource but not succeded.

2 Answers 2

1

if your image is in a zip file you should do it like this:

salesforceImageUrl = Salesforce_Images + '/images/yourImageName.png';
0

for the code you have, try creating a static resource like this Static Resource-> New-> name it 'trailhead_logo' -> Choose file -> Upload the image (not zip file) -> make cache public -> Save

in case if you want to use a zip file as static resource, please share the zip file path for further clarification, as the reference path may vary

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .