• It seems that your plugin does not include images when generating a pdf document when you have a multi instance blog install of the actual wordpress 3.0.1 . It works from inside the “Root-Blog” but it does not work in all the other blogs.

    It just shows this little image with a red cross, standard image for broken links, but if you press on the image you are linked to the web location of the image and it is displayed correctly. I dunno, maybe its because the datastore for the uploads a so different inside the other instances…

    The Pictures inside the Root-Blog are in:
    https://blog.domain.de/wp-content/uploads/2010/06/picture.jpg

    …while the other instances use something like:
    https://blog.domain.de/testblog/files/2010/09/picture.jpg

    The rest seems to work like a charm, thank you very much for contributing your work.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter Khabaal

    (@khabaal)

    Ok i now know whats the Problem. If you are using https for your Blog (force https through apache!) your file urls will of cource have https in their two urls which seems to be a problem with most document viewers like adobe reader free version or the document viewer on ubuntu linux. The reader in Adobe CS4 works perfect though.

    You can manually change the “Source URL” inside the “Extended Settings” of every picture from https to http which would be a solution but our customers would hardly accept that. Changing urls inside the Database does also work but will corrupt the wp-pass plugin for password protecting articles.

    Plugin Author fkrauthan

    (@fkrauthan)

    Hmm i ok i will check somthing then i talk to you again if i have a solution

    Thread Starter Khabaal

    (@khabaal)

    After trying some other pdf generators, which seems to have the same problems when it comes to apaches mod_rewrite and forcing https i stumbled over another generator who fetches the pictures not with http links but directly from the harddisc which could be a possible solution. The problem there was that it was not made for multi-instance use because the picture folders from the instances all have another location on the hdd, but it worked quite well inside the main blog. ??

    Another thing i would like to mention is the image quality inside the generated pdf documents. It uses the thumbnails which are generated by wordpress and does not insert a resize of the original picture which looks kinda awful because wordpress thumbnails are just a pain in the ass when it comes to image quality. Photos do not look that bad inside the pdf documents but when it comes to pictures with statistics it is sometimes hardly possible to clearly read them.
    If i take a look at the filenames it should not be that hard to just cut away the endings to get the correct filename of the original picture *crossing fingers* which would be a great improvement.

    Plugin Author fkrauthan

    (@fkrauthan)

    Hmm aah thats the problem. I use a convertion method to convert the http or https adress do resolve the correct path to a lokal path that must be the problem. But i have no idea where i can read the correct image path from wordpress. If you have a solution i will add it.

    the problem is in myfilters.inc.php
    function mpdf_speedUpLocaleImages($content)
    you look up ‘siteurl’ and substitute ABSPATH

    this might not work for single but it does for multi:
    do it for the single ‘ below it also

    $base_url = get_option('siteurl') . "/" . "wp-uploads";
    $upload_path = get_option('upload_path') . "/";
    
    if(preg_match_all('#<img.*src="(.*)".*>#iU', $content, $matches)) {
        foreach($matches[1] as $ikey => $img) {
            if(strpos($img, $base_url) === 0 ) {
                $local_img_path = str_replace($base_url, '', $img);
                //$new_img = ABSPATH . (substr($local_img_path, 0, 1) === '/' ? substr($local_img_path, 1) : $local_img_path);
                $new_img = $upload_path . (substr($local_img_path, 0, 1) === '/' ? substr($local_img_path, 1) : $local_img_path);
                $content = str_replace('src="'.$img.'"', 'src="file://'.$new_img.'"', $content);
            } else {
                if(substr($img, 0, 1) === '/') {
                    //$new_img = ABSPATH . $img;
                    $new_img = $upload_path . $img;
                    $content = str_replace('src="'.$img.'"', 'src="file://'.$new_img.'"', $content);
                }
            }
        }
    }

    and it works well in 3.0.1
    thanks

    Plugin Author fkrauthan

    (@fkrauthan)

    So i should use get_option(‘upload_path’) . “/”; rigth? Ok i will make a new version soon with this bugfix.

    you will need:
    $base_url = get_option('siteurl') . "/" . "wp-uploads";
    also so as to strip and re-add the position of the wp-uploads part

    the single is ABSPATH/wp-uploads/{premalink>
    the multi is VirtualDocumentRoot/wp-uploads/<domain>/{permalink>

    so you will need to strip the wp-upload part as it is in the get_option(‘upload_path’) for you.

    i know this is true on ubuntu / debian for the multi instance
    i have no single instance running to check this in the mysql entry

    hope this is helpful

    Plugin Author fkrauthan

    (@fkrauthan)

    Ok shoudl be fixed in version 2.5 which should appear soon on the wordpress plugin server.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Plugin: wp-mpdf] No Images when creating PDF Documents in Multi-Instance WordPress’ is closed to new replies.