Posts: 100
Threads: 26
Joined: Dec 2012
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.
Glowczynski.pl - webmaster, graphic designer, translator.
For any job offers contact me via
artur@glowczynski.pl.
Posts: 6,266
Threads: 181
Joined: Sep 2011
You are using urls instead of filepaths you need the actual file path $GSROOT etc
Posts: 100
Threads: 26
Joined: Dec 2012
2016-10-31, 19:42:28
(This post was last modified: 2016-10-31, 19:42:41 by Artur.)
(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.
Glowczynski.pl - webmaster, graphic designer, translator.
For any job offers contact me via
artur@glowczynski.pl.
Posts: 6,266
Threads: 181
Joined: Sep 2011
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
Posts: 100
Threads: 26
Joined: Dec 2012
(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.
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.
Glowczynski.pl - webmaster, graphic designer, translator.
For any job offers contact me via
artur@glowczynski.pl.
Posts: 6,266
Threads: 181
Joined: Sep 2011
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
Posts: 100
Threads: 26
Joined: Dec 2012
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.
Glowczynski.pl - webmaster, graphic designer, translator.
For any job offers contact me via
artur@glowczynski.pl.
Posts: 3,491
Threads: 106
Joined: Mar 2010
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 } ?>
Posts: 100
Threads: 26
Joined: Dec 2012
(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.
Glowczynski.pl - webmaster, graphic designer, translator.
For any job offers contact me via
artur@glowczynski.pl.