Load an icon up only if a file has been loaded up

5 posts by 2 authors in: Forums > CMS Builder
Last Post: April 11, 2014   (RSS)

By Damon - April 9, 2014

Hi,

You can use the file extension code to determine what the file type is:

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

Then either you an if statement (if pdf display pdf icon) or you could control the icons using CSS:

... class="<?php echo $upload['extension'] ?>

Let me know what method you want to go with and I can provide more details.

Cheers,
Damon Edis - interactivetools.com

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

I tried the fle extension option but I obviously wasn't doing it properly, could you give me instructions for both methods for me to try again please.

Thanks for your help.

i have got this working for both pdfs and word documents:

<?php foreach ($mindfulnessRecord['word_uploads'] as $index => $upload): ?>
         <p class="intro"><?php if($upload['extension']=="docx"):?>
               <img src="../images/word-icon.png" width="25" height="28">
<?php endif ?>
          <a href="<?php echo $upload['urlPath'] ?>" target="_blank"><?php echo $upload['info1'] ?></a></p>
<?php endforeach ?>

But I also need it to work for when I load content/links into a wysiwyg editor, can you explain how I can do it that please.

By Damon - April 11, 2014

Hi,

Take a look at this tutorial with icon and code examples:

http://askthecssguy.com/articles/showing-hyperlink-cues-with-css/

CSS like this should get the results I think you are after:

a[href^="http:"] {    
    display:inline-block;    
    padding-right:14px;    
    background:transparent url(/Images/ExternalLink.gif) center right no-repeat;
}

Cheers,
Damon Edis - interactivetools.com

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