Hi ,

I have the origin pull working great, my only issue is that custom content created in the ckeditor in panels the url is not being changed.
I know I could change this manually, but it would be cool if this worked.

Here is the html I added to the ckeditor in panels:

<div id="links_menu">
  <div id="linkz">
		<p>
			<a href="http://www.flaunt.com/current_issue"><img border="0" he src="http://www.flaunt.com/sites/default/files/menu_link_list/magazine_small.png"/></a></p>
		<p>
			<a href="http://www.flaunt.com/flaunt_tv"><img border="0"  src="http://www.flaunt.com/sites/default/files/menu_link_list/video_small.png"/></a></p>

        <p>
			<a href="http://www.flaunt.com/contact"><img border="0"  src="http://www.flaunt.com/sites/default/files/menu_link_list/contact_small.png" /></a></p>
		<p>
			<a href="http://www.flaunt.com/features"><img border="0"  src="http://www.flaunt.com/sites/default/files/menu_link_list/features_small.png" /></a></p>
		<p>
			<a href="http://www.flaunt.com/fashion"><img border="0"  src="http://www.flaunt.com/sites/default/files/menu_link_list/fashion_small.png"/></a></p>
		<p>
            <a href="http://www.flaunt.com/fob"><img border="0"  src="http://www.flaunt.com/sites/default/files/menu_link_list/fob_small.png" /></a></p>
		<p>

			<a href="http://www.flaunt.com/columns"><img border="0"  src="http://www.flaunt.com/sites/default/files/menu_link_list/columns_small.png" /></a></p>
	</div>
</div>

Also, is there a way for the module imagemenu images url to be changed?

Let me know if I can add information to make easier to understand.

thanks,

Nick

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Wim Leers’s picture

Version: 6.x-2.x-dev » 6.x-2.1
Status: Active » Postponed (maintainer needs more info)

1) Regarding CKEditor issues: please read the text over at admin/settings/cdn/other first. Most likely, the same origin policy is the cause for this problem. You may have to blacklist the CKEditor JS file. Try blacklisting all .js files for a moment, and see if that fixes the problem.
2) Regarding imagemenu image URLs: I first need to know the integration method you're using. Are you using the fallback method or did you apply the core patch?

naeluh’s picture

1) I added -

*ckeditor/ckeditor.config.js
*ckeditor/ckeditor.styles.js

I just wanted to confirm that this is the proper path notation fo blacklisting a module .js

2) I have applied the core patch.
I am using the the
http://drupal.org/project/imagemenu
I created a menu using this module to use mouseover/rollover effects in the main menu and put the menu in a block
the top menu at flaunt.com

I am thinking it might have something to do with the js files that the image menu uses

thanks again any help is much appreciated

naeluh’s picture

I think it has something to do with adding images from html rather than the imce cause, the images placed in the ckeditor from the imce work and the images placed there via html do not work

Wim Leers’s picture

Title: Custom Content created thru ckeditor in panels url not being changed ? » Rewrite image URLs in Panels' panes
Category: support » feature
Priority: Major » Normal
Issue tags: +panels

Ah, never mind, it's not that CKEditor is not working, it's that the image URLs are not being altered.

Well, the CDN module uses two ways to alter file URLs:
- URLs defined through all Drupal API calls: hook_file_url_alter()
- URLs in nodes: hook_node_api(), $op = alter

URLs in other pieces of content are not yet being altered. In your case: Panels. I'd welcome a patch that adds support for Panels, or you can sponsor me to add it for you. In the latter case, please contact me via http://wimleers.com/contact.

naeluh’s picture

Status: Postponed (maintainer needs more info) » Active

Alright, I would love to learn how to make a patch, I have never done that before.
You would probably be able to make the changes much faster than I could.
I am more than willing to help in anyway I can. Let me know what I can do to make the process easier for you.

As far as the imagemenu module integration I will be contacting you via contact form on your site.

Thanks again for all your help.

Wim Leers’s picture

If you want to implement it yourself, you can ask the questions here. :)

You only should contact me directly if you want to sponsor something :)

naeluh’s picture

Assigned: Unassigned » naeluh
Wim Leers’s picture

Status: Active » Closed (won't fix)

Closing due to lack of response.

phpbutcher’s picture

Just in case this might help anybody else, here's how we worked around this problem. I'm not a very experienced Drupal guy so any suggestions to optimize this code would be greatly appreciated.

It basically checks to make sure the CDN module exists and is turned on. Then it goes through all the panels in the $display and uses the cdn function to change the img src tags. As I said before, I'm not a Drupal guy so this may not be an optimal solution, but I didn't find anything else in my searches so I figured I'd share. At least it will give people and alternative to changing each image src tag because in a panel.

function myModule_panels_pre_render($display){
  if(module_exists('cdn') && variable_get(CDN_STATUS_VARIABLE, CDN_DISABLED)){
    foreach($display->content as $key => $obj){
      $matches = array();
      $count = 0;
      if(preg_match('/src="(.*?)"/i', $obj->configuration['body'], $matches)){
        if(!empty($matches) && isset($matches[1]) && !stristr($matches[1], 'http')){
          if(preg_match('#(\.jpe?g|\.gif|\.png|\.ico)#i',$matches[1])){
            $search[$count] = $matches[1];
            cdn_file_url_alter(&$matches[1]);
            $replace[$count] = $matches[1];
          }
        }
      }
      $display->content[$key]->configuration['body'] = str_replace($search, $replace, $obj->configuration['body']);
    }
  }
}
jemond’s picture

Status: Closed (won't fix) » Needs review

I used the code from #9 to implement CDN URL rewriting in Panels 3 custom content panes:

function example_preprocess_panels_pane(&$vars) {
  // Check custom panes for images we can send to the CDN. Modified from
  // http://drupal.org/node/1056646#comment-5490392
  if($vars['pane']->type == 'custom' && module_exists('cdn') 
    && variable_get(CDN_STATUS_VARIABLE, CDN_DISABLED)
    && preg_match('/src="(.*?)"/i', $vars['content'], $matches) && !empty($matches) 
    && isset($matches[1]) && !stristr($matches[1], 'http') 
    && preg_match('#(\.jpe?g|\.gif|\.png|\.ico)#i',$matches[1])) {
    
    $original = $matches[1];
    
    // If the path starts with a forward slash remove it, so we don't a
    // double slash.
    $path = substr($original, 0, 1) == '/' ? substr($original, 1) : $original;

    // CDNify the path, as cdn_file_url_alter() will jump in and process this
    // path.
    file_create_url(&$path);

    // Swap in the CDN link.
    $vars['content'] = str_replace($original, $path, $vars['content']);
  }

}

Is this an approach that might go into the module? If so, I'm willing to take a crack at a patch. This patch is currently on our dev server. It will be deployed live probably in December during our next release, so I can circle back and verify the patch is stable.

Wim Leers’s picture

Any reason you can't use cdn_post_render_html_alter(), like I do for blocks: http://drupalcode.org/project/cdn.git/blob/refs/heads/7.x-2.x:/cdn.modul... ?

jemond’s picture

Isn't that only in the D7 version?

jemond’s picture

One fix for the code snippet in #10:

file_create_url(&$path);

should be

$path = file_create_url($path);

Wim Leers’s picture

Version: 6.x-2.1 » 6.x-2.5
Status: Needs review » Needs work

#12: Yes, but in D6 you can use cdn_html_alter_image_urls(). Please use that instead.

jemond’s picture

Ah, cdn_html_alter_image_urls() works. I updated my snippet from #9 to use that instead.

jemond’s picture

cdn_html_alter_image_urls() will not work for my needs. It looks like it assumes that the href for an A tag that wraps an IMG only links to the image itself, and not something else, so it always updates the path of the link to the CDN. In my use case we sometimes have images in custom content panes that link to internal assets on the site, like a registration page, so we don't ever want them rewritten. So I ended up having to revert to the snippet in #9.

Wim Leers’s picture

#16 was fixed some time ago, so now you should be able to use cdn_html_alter_image_urls() again. If you can turn this into a proper patch, I'll commit it :)

jemond’s picture

@wim - Turn what into a patch? The #10 refinement?

Wim Leers’s picture

Yes. But it should be possible to make it much simpler, thanks to cdn_html_alter_image_urls().

Ideally, it would somewhat like this:

/**
 * Implements hook_node_view_alter().
 */
function cdn_node_view_alter(&$build) {
  $build['#post_render'][] = 'cdn_post_render_html_alter';
}
acrollet’s picture

Version: 6.x-2.5 » 7.x-2.x-dev
Status: Needs work » Needs review
FileSize
599 bytes

Here is a patch that translates html in nodes rendered by panels.

Wim Leers’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)
Issue tags: -panels

Automatically closed -- issue fixed for 2 weeks with no activity.

Wim Leers’s picture

acrollet’s picture

Wim Leers: are you expecting some action, or just informing me?