I am using codeigniter for my web development, but when I try to display image on my website in not show. I get image value from the database. When I get image value from database it show me value but image not display, so I want to set default image while it not display image. How can I set default image using Codeigniter?
To Display default image in Codeigniter while it not display image follow this code:
<?php if(!empty($authdata->picture_url)){ $url= $authdata->picture_url; $hdrs = @get_headers($url); $return= is_array($hdrs) ? preg_match('/^HTTP\/\d+\.\d+\s+2\d\d\s+.*$/',$hdrs[0]) : false; if(!$return) $url =$base_url.'assets/images/user_profiles/default.png'; }else{ $url= $base_url.'assets/images/user_profiles/default.png'; } ?>
Question and answer is powered by AnsPress.io