IMAGES won't display in CMS

4 posts by 2 authors in: Forums > CMS Builder
Last Post: October 22, 2010   (RSS)

Re: [mrmzalewski] IMAGES won't display in CMS

By Jason - October 22, 2010

Hi,

Could you attach a .php file where you are displaying an uploaded image?

Thanks.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] IMAGES won't display in CMS

have a look at this:

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php


// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/homepages/45/d281998588/htdocs/casaroccapiccola/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

// load records
list($image_upload2Records, $image_upload2MetaData) = getRecords(array(
'tableName' => 'image_upload2',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$image_upload2Record = @$image_upload2Records[0]; // get first record

// show error message if no matching record is found
if (!$image_upload2Record) {
header("HTTP/1.0 404 Not Found");
print "Record not found!";
exit;
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<style type="text/css">
body { font-family: arial; }
.instructions { border: 3px solid #000; background-color: #EEE; padding: 10px; text-align: left; margin: 25px}
</style>
</head>
<body>

<!-- INSTRUCTIONS -->
<div class="instructions">
<b>Sample Detail Page Viewer - Instructions:</b>
<ol>
<?php ?>
<li><b>Remove any fields you don't want displayed.</b></li>
<li>Rearrange remaining fields to suit your needs.</li>
<li>Copy and paste code into previously designed page (or add design to this page).</li>
</ol>
</div>
<!-- /INSTRUCTIONS -->

<!-- STEP2: Display Records (Paste this where you want your records to be listed) -->
<h1>image_upload2 - Detail Page Viewer</h1>
Record Number: <?php echo $image_upload2Record['num'] ?><br/>
Title: <?php echo $image_upload2Record['title'] ?><br/>
Content: <?php echo $image_upload2Record['content'] ?><br/>
_link : <a href="<?php echo $image_upload2Record['_link'] ?>"><?php echo $image_upload2Record['_link'] ?></a><br/>

<hr/>
<?php if (!$image_upload2Record): ?>
No record found!<br/><br/>
<?php endif ?>
<!-- /STEP2: Display Records -->

<a href="<?php echo $image_upload2MetaData['_listPage']; ?>">&lt;&lt; Back to list page</a> -
<a href="mailto:?subject=<?php echo thisPageUrl() ?>">Email this Page</a>
</body>
</html>


http://s281998607.websitehome.co.uk/casaroccapiccola/test2.php

images show in CMS both thumbnails and the ones on the backpage, but do not display in the web browser. heres the link witha prtsc of my settings (again images in cms work, but not in the actual web browser!):
http://s281998607.websitehome.co.uk/casaroccapiccola/urls.jpg

Re: [mrmzalewski] IMAGES won't display in CMS

By Jason - October 22, 2010

Hi,

There is actually no code on this page that outputs an image. You're only outputting the record number, title, content, and link fields.

If the images are showing up in CMS Builder, that means you're using the correct path. What you need to do is to output the image to the screen.

In this example, I'm going to assume the name of your upload field is called "upload". If it's not, just change that name in the code example:

<?php if($image_upload2Record['upload']): ?>
<?php $image = $image_upload2Record['upload'][0]; ?>
<img src="<?php echo $image['urlPath'];?>" />
<?php endif ?>


This code will output the first image uploaded to that record.

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/