Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8639877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:07:59+00:00 2026-06-12T11:07:59+00:00

I have a database with images associated to each entry. Anyhow, some entries don’t

  • 0

I have a database with images associated to each entry.

Anyhow, some entries don’t have an image.

Googling I found some js and php way to apply in the view, but I’m pretty sure there is a (much nicer) MVC-way to do this, just I don’t know how..

Is there a nice Cake-way to display placeholder image where none exist?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T11:08:02+00:00Added an answer on June 12, 2026 at 11:08 am

    Supposed the data you set from the controller named ‘post’. And you have ‘your_default_image’ in your /app/webroot/img/

    <?php
    if(empty($post['Post']['img'])) {
        echo $this->Html->image($post['Post']['img']);
    } else {
        echo $this->Html->image('your_default_image');
    }
    

    And you can wrap those logic in your helper.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have the following code that generate some images with urls associated from database:
I have a database with Car Histories. Each car history has multiple images associated
I have saved an image path in database like so: C:\Users\3embed\Documents\Visual Studio 2010\Projects\HeritageWeb\HeritageWeb\Images\startbutton.png I
Basically I have a database with two tables, that is, Updates table and Images
I have 400 images in my server database. I am able to get those
I have links of images in my database e.g.-http://accessories.us.dell.com/sna/images/products/large/330-5288.jpg above link of an image
I have fetched images and text as listview from database.now on clicking the particular
I have an application that stores images in a database. Now I have learned
I have these images that I am getting off my server and a database
I have a controller in MVC serving up images from a database. EDIT: This

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.