Jump to content

Recommended Posts

There is probably a better way of doing this but the problem I'm having is it puts the images at the top of the page (before EVERYTHING else).

 

The PHP is in a loop, so it looks at 5 different strings then echos the image. here's my code ($r['content'] being the string it looks for the image).

 

Funtion:

<php>

ob_start();

function bm_extract_string($start, $end, $original) {

$original = stristr($original, $start);

$trimmed = stristr($original, $end);

return substr($original, strlen($start), -strlen($trimmed));

}

</php>

 

Echo bit (this is in a loop):

<php>

$content = $r['content'];

$pic_string = bm_extract_string("src='","' ",$content);

echo '<img src="'.$pic_string.'" />';

</php>

 

 

Any ideas? I don't think the page code will make much sense as it's IPB3 but here it is:

 

<php>
ob_start();
function bm_extract_string($start, $end, $original) {
$original = stristr($original, $start);
$trimmed = stristr($original, $end);
return substr($original, strlen($start), -strlen($trimmed));
}
</php>

<script type='text/javascript'>
                Event.observe( window, 'load', function(){
                        // Resize images
                        $$('.hentry').each( function(elem){
                                ipb.global.findImgs( $( elem ) );
                        });
                });
</script>



<ul class='hfeed'>
	<if test="is_array( $records ) && count( $records )">
	{parse striping="feed_striping"}



<foreach loop="$records as $r">
	<li style="padding:10px" class='hentry {parse striping="feed_striping"}'>

<php>
$content = $r['content'];
$pic_string = bm_extract_string("src='","' ",$content);
echo '<img src="'.$pic_string.'" />';
</php>

<a href='{$r['url']}' rel='bookmark' title='{$r['title']}'><h2 style="font-size:24px; font-weight:bold; margin-bottom:0px; border-bottom:1px #284B72 solid; width:100%">{$r['title']}</h2></a>

<div style="float:left; padding-top:2px">
<div class="addthis_toolbox addthis_default_style">
<a href="http://www.addthis.com/bookmark.php?v=250&pub=xa-4b08040306d7ea55" class="addthis_button_expanded">Share</a>
<span class="addthis_separator">|</span>
<a class="addthis_button_digg"></a>
<a class="addthis_button_twitter"></a>
<a class="addthis_button_reddit"></a>
<a class="addthis_button_delicious"></a>
<a class="addthis_button_favorites"></a>
<a class="addthis_button_print"></a>
</div>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pub=xa-4b08040306d7ea55"></script>
</div>

<span style="float:right; font-size:11px; font-weight:bold; color:#000066">
<img src="files/comments.gif" alt="" /> 
<a href='{$r['url']}' rel='bookmark' title='{$r['title']}'>{$r['topic_posts']} comment<if test="$r['topic_posts'] > 1">s</if></a> | 
<b><abbr class="published" title="{parse expression="date( 'c', $r['date'] )"}">{parse date="$r['date']" format="short"}</b></abbr>
</span>
<br /><br />

<div class='desctext' style="padding-left:25px">{$r['content']}
</div>
	</li>
<br />
</foreach>

	</if>
</ul>
<br /><br />

 

Thanks in advance.

try

<?php
function bm_extract_string($start, $end, $original) {
$original1 = stristr($original, $start);
$trimmed = stristr($original, $end);
return substr($original, $origil1+strlen($start), $trimmed-$original1-strlen($start));
}
$content = $r['content'];
$pic_string = bm_extract_string("src='","' ",$content);
echo '<img src="'.$pic_string.'" />';
?>

try

<?php
function bm_extract_string($start, $end, $original) {
$original1 = stristr($original, $start);
$trimmed = stristr($original, $end);
return substr($original, $origil1+strlen($start), $trimmed-$original1-strlen($start));
}
$content = $r['content'];
$pic_string = bm_extract_string("src='","' ",$content);
echo '<img src="'.$pic_string.'" />';
?>

 

No, that didn't work either.

ups

<?php
function bm_extract_string($start, $end, $original) {
$original1 = stripos($original, $start);
$trimmed = stripos($original, $end);
return substr($original, $original1+strlen($start), $trimmed-$original1-strlen($start));
}
$content = $r['content'];
$pic_string = bm_extract_string("src='","' ",$content);
echo '<img src="'.$pic_string.'" />';
?> 

Is that just with the spelling corrections? I spotted those and fixed them before.  :D But sadly it didn't work either.

 

I don't know why, it just seems to be dumping PHP at the very top of the page. Even if I don't use a function to do the job.

i try this code

<?php
function bm_extract_string($start, $end, $original) {
$original1 = stripos($original, $start);
$trimmed = stripos($original, $end);
return substr($original, $original1+strlen($start), $trimmed-$original1-strlen($start));
}
//$content = $r['content'];
$content = "bla bla bla src='picture.bmp' bla bla";
$pic_string = bm_extract_string("src='","' ",$content);
echo '<img src="'.$pic_string.'" />';
?> 

and it outputs

<img src="picture.bmp" />

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.