We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

remove_double_slashes not working

Development and Programming

box-head's avatar
box-head
177 posts
15 years ago
box-head's avatar box-head

Can anyone see why this wouldn’t work.

$src = "/images/uploads/test-image.jpg";
$src = "/".$src;

$src = $this->EE->functions->remove_double_slashes($src);

//$src returns "//images/uploads/test-image.jpg"

Using this within a plugin.

EE v2.1.0 Build 20101020

Thanks

       
John Henry Donovan's avatar
John Henry Donovan
12,339 posts
15 years ago
John Henry Donovan's avatar John Henry Donovan

box-head,

What happens if you use it within a template?

It works there for me

<?php

$src = "/images/uploads/test-image.jpg";
$src = "/".$src;

$src = $this->EE->functions->remove_double_slashes($src);

//$src returns "/images/uploads/test-image.jpg"

echo $src

?>

If it works there can you provide some more of what your plugin is doing please

       
box-head's avatar
box-head
177 posts
15 years ago
box-head's avatar box-head

Hi John,

Up to that point all I have done is grab the provided source from a parameter.

$src = (! $this->EE->TMPL->fetch_param('src')) ? '' : $this->EE->TMPL->fetch_param('src');

$src = $this->EE->functions->remove_double_slashes("/".$src);

return $src;

Thanks

       
box-head's avatar
box-head
177 posts
15 years ago
box-head's avatar box-head

Debugging a little further, the problem occurs when using the plugin within the imgsier plugin.

Like so.

{exp:imgsizer:size src="{event-image}" width="1020" height="420"}
    {exp:new_plugin:method src="{sized}"}
{/exp:imgsizer:size}

Imgsizer outputs {sized} which equals /images/sized/images/uploads/photo.jpg New_plugin then outputs //images/sized/images/uploads/photo.jpg

Is it supposed to be possible to nest plugins like this?

       
Sue Crocker's avatar
Sue Crocker
26,054 posts
15 years ago
Sue Crocker's avatar Sue Crocker

Hi, box-head. I’m moving the thread to the Development forum.

       
box-head's avatar
box-head
177 posts
15 years ago
box-head's avatar box-head

Thanks Sue,

From an EE point of view should I technically be able to nest plugins like I have? Or would it be better practise to actually embed it using second template?

Any insight would be very helpful. Thanks

       
box-head's avatar
box-head
177 posts
15 years ago
box-head's avatar box-head

As an update - I got the the functionality I require working using an embed like so.

{exp:imgsizer:size src="{image}" width="1020" height="420" alt="{title}"}
    {embed=embeds/image-modify file="{sized}"}
{/exp:imgsizer:size}

then in embeds/image-modify

{exp:my_plugin:method src='{embed:file}'}

The earlier problem actually seemed to be that the variable {sized} from imgsizer wasn’t returning a src by the time my plugin used it, so the value of my “src” parameter was using the string “{sized}” rather than an actual src value such as /images/sized/uploads/file.jpg

I assume this is something to do with the parse order? Is that right?

Is using an embed the most suitable way to nest plugins like this or am I missing something? Thanks

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.