Slight Problem Noticed

8 posts by 2 authors in: Forums > CMS Builder
Last Post: March 12, 2015   (RSS)

By zaba - March 12, 2015

Hi an unusual problem has presented itself.

Some of my clients are uploading images with brackets in the title, for example 'this_image_(2).jpg'

Now this does not effect anything when the image is on the page i.e. <img src="/cms/uploads/this_image_(2).jpg" alt="This Image" width="151" height="214">

but when it is set as a background image it conflicts with css and does not display i.e. 

<div class="pressbox" style="background-image: url(/cms/uploads//this_image_(2).jpg);"></div>

Is there anyway to strip out brackets in filenames (as you do with spaces) at the time the file is uploaded in the cms?

Is there a fix we can implement straight away in the code somewhere, which can then be built in to future releases.

By gkornbluth - March 12, 2015 - edited: March 12, 2015

Hi Zaba,

Try a preg_replace in your foreach loop, something like this (change the thumbUrlPath as approriate).

It's based on a regex recipe in my CMSB Cookbook http://www.thecmsbcookbook.com

<?PHP $upload['thumbUrlPath'] = preg_replace("[\(|\)]", "-", $upload['thumbUrlPath'] ); ?>

 Best,

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By zaba - March 12, 2015

Thanks Greg,

but the filenames need to be renamed automatically to remove brackets at the point of upload. (I have no control over the names clients call their images)

If I do it where you suggest the file will not exist (as it will be looking for a filename that does not exist).

By gkornbluth - March 12, 2015

Oops, you're right. Silly me...

Sorry

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By gkornbluth - March 12, 2015 - edited: March 12, 2015

But this might help...

http://www.interactivetools.com/forum/forum-posts.php?postNum=2236111

Sometimes it's hard to remember what you did only a few days ago,,,

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By gkornbluth - March 12, 2015

It doesn't, I was using that variable to enter test server URLS at the time.

Just put a set of single quotes ' around your url, or foreach loop, or whatever code you're using to pull up the image path in your background-image: url('your code')

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By zaba - March 12, 2015

Ahhh.

Got you!

and it works!!

thanks Jerry!!!