image null check
This commit is contained in:
parent
248a80727a
commit
477286fe45
@ -2,7 +2,7 @@ import { dirname } from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
import { FlatCompat } from "@eslint/eslintrc";
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __filename = fileURLToPath(import.meta?.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
const compat = new FlatCompat({
|
||||
|
||||
@ -8,6 +8,9 @@ class StrapiClient{
|
||||
constructor(private strapiUrl: string = "http://localhost:1337") {
|
||||
}
|
||||
public getImageUrl(imagePath: string){
|
||||
if ( !imagePath ){
|
||||
return "dummy.png"
|
||||
}
|
||||
return '/image/'+ imagePath;
|
||||
}
|
||||
public async httpGet(path: string){
|
||||
|
||||
@ -16,7 +16,7 @@ const AboutUsComponent = ( {data: {title,header,description,content,buttonText,b
|
||||
<div className="row">
|
||||
<div className="col-lg-7 col-md-7 col-sm-12 col-xs-12">
|
||||
<div className="aboutus_image">
|
||||
<figure className="mb-0"><YogaImageComponent src={strapiApi.getImageUrl(fileImage.url)} alt="" className="img-fluid"/></figure>
|
||||
<figure className="mb-0"><YogaImageComponent src={strapiApi.getImageUrl(fileImage?.url)} alt="" className="img-fluid"/></figure>
|
||||
</div>
|
||||
<figure className="aboutus_top_shape left_shape mb-0">
|
||||
<YogaImageComponent src="/assets/images/aboutus_top_shape.png" alt="" className="img-fluid"/>
|
||||
|
||||
@ -14,7 +14,7 @@ const BlogSinglePostComponent = ({post: {header,teaserImage,tags,documentId} }:
|
||||
<div className="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
||||
<div className="blog_posts_image position-relative">
|
||||
<figure className="mb-0">
|
||||
<YogaImageComponent src={strapiApi.getImageUrl( teaserFile.url ) } alt=""
|
||||
<YogaImageComponent src={strapiApi.getImageUrl( teaserFile?.url ) } alt=""
|
||||
className="img-fluid"/>
|
||||
</figure>
|
||||
<div className="blog_posts_image_content">
|
||||
|
||||
@ -16,7 +16,7 @@ const FeedbackComponent = ({active,config: {customerName, feedback, customerImag
|
||||
<div className="testimonial_content">
|
||||
<i className="fa-solid fa-quote-left"></i>
|
||||
<p className="testimonial_paragraph">“{feedback}”</p>
|
||||
<figure><YogaImageComponent src={strapiApi.getImageUrl(imageFile.url)} alt=""
|
||||
<figure><YogaImageComponent src={strapiApi.getImageUrl(imageFile?.url)} alt=""
|
||||
className="img-fluid"/></figure>
|
||||
<p className="testimonial_person_name">{customerName}</p>
|
||||
<span>{customerDescription}</span>
|
||||
|
||||
@ -15,7 +15,7 @@ const OurServiceItemComponent = ({config: {header,description,image}}: Props) =>
|
||||
<div className="services_box_content">
|
||||
<div className="services_box_upper_portion">
|
||||
<figure className="mb-0">
|
||||
<YogaImageComponent src={strapiApi.getImageUrl(imageFile.url)} alt="" className="img-fluid"/>
|
||||
<YogaImageComponent src={strapiApi.getImageUrl(imageFile?.url)} alt="" className="img-fluid"/>
|
||||
</figure>
|
||||
</div>
|
||||
<div className="services_box_lower_portion">
|
||||
|
||||
@ -11,17 +11,17 @@ export function PriceItemComponent({config: {header,option1,option2,price,icon,
|
||||
// there are some issues with the strapi generated types
|
||||
const iconFile: StrapiFile = icon as StrapiFile;
|
||||
const imageFile: StrapiFile = image as StrapiFile;
|
||||
console.info("image:",strapiApi.getImageUrl(imageFile.url));
|
||||
console.info("image:",strapiApi.getImageUrl(imageFile?.url));
|
||||
return (
|
||||
<div className="col-lg-4 col-md-4 col-sm-6 col-xs-12">
|
||||
<div className="pricing_plans_box_content">
|
||||
<div className="pricing_plans_box_upper_portion">
|
||||
<figure className="pricing_plans_image mb-0">
|
||||
<YogaImageComponent src={strapiApi.getImageUrl(imageFile.url)} alt="" className="img-fluid"/>
|
||||
<YogaImageComponent src={strapiApi.getImageUrl(imageFile?.url)} alt="" className="img-fluid"/>
|
||||
</figure>
|
||||
<div className="pricing_plans_box_image_content">
|
||||
<figure className="mb-0">
|
||||
<YogaImageComponent src={strapiApi.getImageUrl(iconFile.url)} alt=""
|
||||
<YogaImageComponent src={strapiApi.getImageUrl(iconFile?.url)} alt=""
|
||||
className="img-fluid"/>
|
||||
</figure>
|
||||
</div>
|
||||
|
||||
@ -11,7 +11,7 @@ export default function TextWithRightImage ({config: {
|
||||
}}: Props){
|
||||
|
||||
const strapiFile = image as StrapiFile;
|
||||
const imageUrl = strapiApi.getImageUrl(strapiFile.url)
|
||||
const imageUrl = strapiApi.getImageUrl(strapiFile?.url)
|
||||
|
||||
return (
|
||||
<section className="mission_section">
|
||||
|
||||
@ -12,7 +12,7 @@ export default function TextWithLeftImage ({config: {
|
||||
}}: Props){
|
||||
|
||||
const strapiFile = image as StrapiFile;
|
||||
const imageUrl = strapiApi.getImageUrl(strapiFile.url)
|
||||
const imageUrl = strapiApi.getImageUrl(strapiFile?.url);
|
||||
|
||||
|
||||
return (
|
||||
|
||||
Loading…
Reference in New Issue
Block a user