GetSimple Support Forum
QUESTION Image verification - Printable Version

+- GetSimple Support Forum (http://get-simple.info/forums)
+-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3)
+--- Forum: Developer Discussions (http://get-simple.info/forums/forumdisplay.php?fid=8)
+--- Thread: QUESTION Image verification (/showthread.php?tid=8807)



Image verification - Artur - 2016-10-31

Can somebody verify that code for me and write why it is not working? http://pastebin.com/dXPYW2Cm

I want to make a code which will check if there's an image and - if it is - show it. Im using GetSimple tags to generate image address (like mysite.com/data/uploads/pageslug.jpg), but this code is not working, IDK why.


RE: Image verification - shawn_a - 2016-10-31

You are using urls instead of filepaths you need the actual file path $GSROOT etc


RE: Image verification - Artur - 2016-10-31

(2016-10-31, 06:49:00)shawn_a Wrote: You are using urls instead of filepaths you need the actual file path $GSROOT etc

Could you write that code for me to make it work? I'm trying to do that on my own but it still doesn't work.


RE: Image verification - shawn_a - 2016-10-31

PHP Code:
<?php
$filename 
GSDATAUPLOADPATH .  get_page_slug() . '.jpg';
$fileurl get_site_url() . 'data/uploads/' get_page_slug() . '.jpg'
something like that, you are already in php also , why do you have inline php tags


RE: Image verification - Artur - 2016-11-01

(2016-10-31, 23:32:49)shawn_a Wrote:
PHP Code:
<?php
$filename 
GSDATAUPLOADPATH  get_page_slug() . '.jpg';
$fileurl get_site_url() . 'data/uploads/' get_page_slug() . '.jpg'
something like that, you are already in php also , why do you have inline php tags

Code was written by my friend, because I am not a PHP master, but I wanted a feature I cannot write on my own. Wink


I made something like this:


PHP Code:
<?php
$filename 
GSDATAUPLOADPATH  get_page_slug() . '.jpg';
$fileurl get_site_url() . 'data/uploads/' get_page_slug() . '.jpg';

$headers=get_headers($filename);
 
if (
$headers[0] == 'HTTP/1.1 200 OK') {
 
   echo $fileurl;
} else {
 
   echo "";
?>
But after saving it shows something like this: sample-pagehttp://base.kingarchee.pl/getsimple/demos/gsStellar/sample-page whitout .jpg format and proper address.


RE: Image verification - shawn_a - 2016-11-01

What are you trying to do why are you outputing headers i thought you were editing your template, it looks like you are making a dynamic im request file.
Just modify your template


RE: Image verification - Artur - 2016-11-01

I made a theme which has ability to show .jpg images on specified page if this image has the slug in it's name. Like if i have /sample-page/, it will show sample-page.jpg file. But if there's no image, the broken link will occur. I want to delete this broken link and show nothing when there's no such image, and show it if it is in uploads.


RE: Image verification - Carlos - 2016-11-01

PHP Code:
<?php if (file_exists(GSDATAUPLOADPATH.get_page_slug(false).'.jpg')) { ?>
  <span class="image main"><img src="<?php get_site_url(); ?>data/uploads/<?php get_page_slug(); ?>.jpg" alt="" /></span>
<?php ?>



RE: Image verification - Artur - 2016-11-01

(2016-11-01, 18:02:41)Carlos Wrote:
PHP Code:
<?php if (file_exists(GSDATAUPLOADPATH.get_page_slug(false).'.jpg')) { ?>
  <span class="image main"><img src="<?php get_site_url(); ?>data/uploads/<?php get_page_slug(); ?>.jpg" alt="" /></span>
<?php ?>       

Nice, it works! Thank you very much, Carlos. Smile