close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

removing an image

Thread began 2/25/2013 11:25 am by JamieEff | Last modified 2/26/2013 11:11 am by Jason Byrnes | 428 views | 7 replies |

JamieEff

removing an image

Hey Jason

I have a blog panel which summarises the content and title of the most recent post. If an image is added to the main content area this also gets added to the panel.

How would I remove the image from the panel... I have tried

<?php echo(str_replace(array("<p>","</p>","<img />","<a>","</a>"),"",(substr($row_BlogRS['BlogContent'],0,120)." ..."))); ?>



Thats doesnt work so just wondering if you could give me a steer please?

Thanks

Jamie

Sign in to reply to this post

Jason ByrnesWebAssist

you would need to use preg_replace for that. see this thread at stack overflow for an example:

php-remove-img-tag-from-string

Sign in to reply to this post

JamieEff

Thanks Jason

I have been trying to work out the right format for this but cant seem to get it to work.

What I have 'ended' up with is:

php:
<?php echo (preg_replace("/<img[^>]+\>/i"" ",(str_replace(array("<p>","</p>"),"",(substr($row_BlogRS['BlogContent'],0,120)." ..."))))); ?>
Sign in to reply to this post

Jason ByrnesWebAssist

what is the raw html output of:

php:
<?php echo($row_BlogRS['BlogContent']); ?>



from that I can help with the preg_replace command

Sign in to reply to this post

JamieEff

its the top panel ('latest blog post') on this page (and all other pages apart from the homepage:

about.php

Sign in to reply to this post

Jason ByrnesWebAssist

the preg_replace() should be done on the main string, before the other substr() and str_replace() functions:

php:
<?php echo(str_replace(array("<p>","</p>"),"",substr(preg_replace("/<img[^>]+\>/i"" ",$row_BlogRS['BlogContent']),0,120))."..."); ?>
Sign in to reply to this post

JamieEff

brilliant thanks Jason

in the same context and taking it a little further, if I wanted to remove a link I was wondering if I am on the right path here:

php:
<?php echo(str_replace(array("<p>","</p>"),"",substr(preg_replace("/<img[^>]+\>/i","/\<a([^>]*)\>([^<]*)\<\/a\>/i"" ",$row_NewsRS['NewsContent']),0,120))."..."); ?>



where the link content would remain byt the <a> tags would be removed....

Sign in to reply to this post

Jason ByrnesWebAssist

your getting into custom development now.

you can't feed a comma separated list of regular expressions to the preg_replace function like this, though.

with the complexity that you are trying to accomplish, you would be better creating a function rather than stringing each command together like you are doing. If you need further assistance, a premiere support appointment would be the way to go.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...