how can I make a swf appear like an image when uploaded?

5 posts by 2 authors in: Forums > CMS Builder
Last Post: October 23, 2008   (RSS)

By TheSeen - October 16, 2008 - edited: October 16, 2008

Hi all ...

Loving the CMS software. I have been using your products for it must be over 5 years and have to say that CMS is a fantastic leap and very powerful package ... well done.

Anyway, I have added an upload setting in the section editor for the site that I am working on and would like to upload a swf ... but with the swf file embedded and running in the actual website page.

Much like a picture gets added to a page using upload ... but instead it's a swf.

At the moment the content system is treating the swf file as a download link ... so displays nothing but a download text link to the swf file.

You advise is much appreciated.

Adrian

Re: [The Seen] how can I make a swf appear like an image when uploaded?

By Dave - October 17, 2008

Hi Adrian,

So glad to hear your enjoying CMS Builder! :)

To answer your question. The first step is to figure out what HTML you want inserted for swf files. You can find details about that here: http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_4150

Next, If you know you're _only_ going to be uploading swf files in that upload field you can hardcode it to always show uploads with your swf html like this:

<?php foreach ($newsRecord['uploads'] as $upload): ?>
<embed src="<?php echo $upload['urlPath?>" ... /><br/>
<?php endforeach ?>


Or if you're going to have images and swf in the same field you can test the file extension to figure out what html to insert for each upload:

<?php foreach ($newsRecord['uploads'] as $upload): ?>
<?php if ($upload['extension'] == 'swf'): ?>
... html code for swf files ...
<?php elseif ($upload['hasThumbnail']): ?>
... html code for thumbnails ...
<?php elseif ($upload['isImage']): ?>
... html codes for images (if there is no thumbnail) ...
<?php else: ?>
... html code for other file types (this could be a download link) ...
<?php endif; ?>
<?php endforeach ?>


Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [The Seen] how can I make a swf appear like an image when uploaded?

By Dave - October 22, 2008

Hi Adrian,

So all you need is to remove the file extension (.swf) from the end? Here's some code for that:

<?php $upload['urlPathNoExt'] = preg_replace('/\.\w+$/', '', $upload['urlPath']); ?>

Just put that inside the foreach loop but above where you want to use it. Then display it like this:

<?php echo $upload['urlPathNoExt'] ?>

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] how can I make a swf appear like an image when uploaded?

By TheSeen - October 23, 2008 - edited: October 23, 2008

Genius David!

Awesome works a treat ... you make it look so simple.
Outstanding software package ... I can see I'll be using this for years to come.

Thanks again for the swift reply.

Kind regards
Adrian