• Hello,

    I am using the plugin Ad Injection and I am having some problems with ads overlapping onto images. These are 300×250 ads that I float either left or right. Is there a way to add a buffer of so many words between an ad and images?

    Thank you.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi lelandmcfarland. There is no way to add a buffer around images, but this is something I may add one day in the distant future.

    Have you tried using the plain ‘left’ or ‘right’ align options instead of the ‘float left’ and ‘float right’?

    Thread Starter lelandmcfarland

    (@lelandmcfarland)

    Ya, but it doesn’t work for what I want to do, plus it is nice to have a little word space between the ads and the images to avoid clutter. With that, I just added a little hack in order to give myself a 600 character buffer between the ads and the images. Thank you anyways.

    Hi lelandmcfarland, would you be willing to share your hack? I’d be interested in seeing how you did it. Thanks.

    Thread Starter lelandmcfarland

    (@lelandmcfarland)

    Sure. Here you go:

    function smb_find_occurences($string, $find) {
      if (strpos(strtolower($string), strtolower($find)) !== FALSE){
        $pos = -1;
        for ($i=0; $i<substr_count(strtolower($string), strtolower($find)); $i++){
          $pos = strpos(strtolower($string), strtolower($find), $pos+1);
          $positionarray[] = $pos;
        }
        return $positionarray;
      }else{
        return false;
      }
    }
    $image_positions = smb_find_occurences($content, '<img');
    if(count($image_positions)){
      if(count($potential_random_ad_paragraphs)){
        foreach($potential_random_ad_paragraphs as $key=>$potential_random_ad_paragraph){
          foreach($image_positions as $image_position){
            if(abs($image_position - $original_paragraph_positions[$potential_random_ad_paragraph-1]) < 600){
              unset($potential_random_ad_paragraphs[$key]);
            }
          }
        }
      }
    }

    I inserted this section of cod into line 869 in ad-injection.php. Sorry if it is a little crude, I was going more for time rater then efficiency. There are probably some better ways to determine image position in the content, as the method I used does not take into account the length of the image tag.

    Hi lelandmcfarland, thanks a lot for sharing that. I’ve made a note of your code, and that may well help this feature to appear in the plugin sooner than it otherwise would. Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: Ad Injection] Avoiding Images’ is closed to new replies.