1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Post Images 1.8

Add thumb images to your posts

  1. sereban

    sereban Active Member

    I'm sorry, summernote not had to work in the old version submit.
     
  2. valMETNG

    valMETNG Administrator Staff Member Admin

    This looks right, so I'm not sure what the problem is. Are you getting any errors in your error_log? If not, why don't you zip up your entire post_images directory and post it here? I'll take a look.
     
  3. valMETNG

    valMETNG Administrator Staff Member Admin

    I'm sorry, but I don't understand what you wrote. Is summernote still not working for your or it works now that you have updated to the latest version? If you're still having problems with summernote, please post a comment in the submit thread.
     
  4. sereban

    sereban Active Member

    I downloaded the latest version of the post-image, there is a line 340, I added your code, and it still does not work. Is post-Image plugin that comes with Hotaru 1.7.2 must be identical to the latest version of the plug-in post-image resource. I think that there are plug-ins that the latest version will be different from the plug-ins that come with Hotaru 1.7.2. Perhaps for this reason, you are work the code, and I have not worked.
     
  5. valMETNG

    valMETNG Administrator Staff Member Admin

    That could be. Perhaps @shibuya246 can confirm the latest version of the plugin is the one in the forum thread. In the meantime, if you post your post_images directory here as a zipped file (or message me it), I can look.
     
  6. sereban

    sereban Active Member

    The archive post-image of Hotaru 1.7.2. This fragment is the latest version of the resource.
    Code:
       line 314   if($h->cage->post->getAlpha('type') == 'postImages' && $h->cage->post->testUri('url')){                 
                $html =  file_get_contents($h->cage->post->getHtmLawed('url'));
                $html = $this->addImages($h, $url, $html);
                $parseUrl = parse_url(trim($h->cage->post->getHtmLawed('url')));
                $hostname = trim($parseUrl['host'] ? $parseUrl['host'] : array_shift(explode('/', $parseUrl['path'], 2)));
                $html = str_replace('src="/','src="'.$parseUrl['scheme'].'://'.$hostname.'/',$html);
                $html = str_replace("src='/","src='".$parseUrl['scheme']."://".$hostname.'/',$html);
                preg_match_all('/( src=["\']{1}(?!http)\w{1})/',$html,$result, PREG_OFFSET_CAPTURE);
                echo '<pre>';
                //$matches =  is_array($result) ? array_unique($result) : array($result);
                            //error when trying to get unique items on array
                            $matches = $result;
                //print_r($matches);
                $rel_dir = (substr($parseUrl['path'],-1) == '/' || strlen($parseUrl['path']) == 0 ? $parseUrl['path'] : dirname($parseUrl['path']).'/');
                $rel_path = $parseUrl['scheme']."://".$hostname.$rel_dir;
                $rel_div_l = strlen($rel_path);
                $i = 0;
                foreach($matches[0] as $match){
                    echo $rel_div_l.' '.var_dump($match[1]);
                    echo '-'.$match[1]+6+$i*$rel_div_l."\n";
                    $html = substr($html,0,$match[1]+6+$i*$rel_div_l) . $rel_path . substr($html,$match[1]+6+$i*$rel_div_l);
                    $i++;
                }
                echo '</pre>';
                echo $html;
                die();
            }
        }
    function addImages($h, $url, $html)
       {
         // to get youtube id and add picture as image - from http://stackoverflow.com/questions/9594943/regex-pattern-to-get-the-youtube-video-id-from-any-youtube-url and http://stackoverflow.com/questions/16222407/url-of-large-image-of-a-youtube-video
         // to get vimeo id and add picture as image - from http://stackoverflow.com/questions/10488943/easy-way-to-get-vimeo-id-from-a-vimeo-url and http://stackoverflow.com/questions/1361149/get-img-thumbnails-from-vimeo
    
         if (!$html) { return false; }
    
         $site = false;
         $values = false;
    
         $site_regex = array(
           'youtube' => array(
             '/youtube\.com\/watch\?v=([^\&\?\/]+)/',
             '/youtube\.com\/embed\/([^\&\?\/]+)/',
             '/youtube\.com\/v\/([^\&\?\/]+)/',
             '/youtu\.be\/([^\&\?\/]+)/',
             '/youtube\.com\/verify_age\?next_url=\/watch%3Fv%3D([^\&\?\/]+)/'
           ),
           'vimeo' => array(
             "/(https?:\/\/)?(www\.)?(player\.)?vimeo\.com\/([a-z]*\/)*([0-9]{6,11})[?]?.*/"
           )
         );
    
         foreach ($site_regex as $site_name => $regex_array)
         {
           foreach ($regex_array as $regex)
           {
             if (preg_match($regex, $url, $id))
             {
               $values = $id;
               $site = $site_name;
               break;
             }
    
             if ($values) { break; }
           }
         }
    
         // if there was an id, we will add as image
         if ($values)
         {
           switch ($site)
           {
             case 'youtube':
               $search = '<span class="yt-thumb-clip">';
               $replace = $search . '<img src="http://img.youtube.com/vi/' . $values[1] . '/0.jpg" >';
               break;
             case 'vimeo':
               $search = '<header id="page_header">';
               $hash = unserialize(file_get_contents("http://vimeo.com/api/v2/video/" . $values[5] . ".php"));
    
               if (!$hash) { return $html; }
    
               $replace = $search . '<img src="' . $hash[0]['thumbnail_medium'] . '" >';
               break;
             default:
               return $html;
           }
    
           $html = str_replace($search, $replace, $html);
         }
    
         return $html;
       }
        }
    ?>
     

    Attached Files:

  7. valMETNG

    valMETNG Administrator Staff Member Admin

    Thank you. That helped me find the problem. $url isn't defined (it is in my build). To call the function, use this instead for line 316:
    Code:
    $html = $this->addImages($h, $h->cage->post->getHtmLawed('url'), $html);
     
    sereban likes this.
  8. sereban

    sereban Active Member

    YouTube miniature works fine. Vimeo does not work.
     
  9. valMETNG

    valMETNG Administrator Staff Member Admin

    I just tested a random vimeo video and it worked (e.g., https://vimeo.com/channels/staffpicks/104480777). Can you please give me the URL of the video that doesn't work?
     
    sereban likes this.
  10. sereban

    sereban Active Member

    Attached Files:

  11. valMETNG

    valMETNG Administrator Staff Member Admin

    Attached are the files that work in my base build. Can you try these please? If these don't work, please check your error_log.php for errors and post them here. There must be something different/modified in your build if that URL is not working.
     

    Attached Files:

  12. sereban

    sereban Active Member

    Vimeo does not work.
    [21-Apr-2015 04:04:59 Europe/Paris] PHP Warning: filesize(): stat failed for C:\wamp\www\hunttheme/cache/debug_logs/system_report.php in C:\wamp\www\hunttheme\libs\Debug.php on line 162

    [21-Apr-2015 04:04:59 Europe/Paris] PHP Stack trace:

    [21-Apr-2015 04:04:59 Europe/Paris] PHP 1. {main}() C:\wamp\www\hunttheme\admin_index.php:0

    [21-Apr-2015 04:04:59 Europe/Paris] PHP 2. Libs\Hotaru->start() C:\wamp\www\hunttheme\admin_index.php:32

    [21-Apr-2015 04:04:59 Europe/Paris] PHP 3. Libs\Hotaru->adminPages() C:\wamp\www\hunttheme\Hotaru.php:99

    [21-Apr-2015 04:04:59 Europe/Paris] PHP 4. Libs\AdminPages->pages() C:\wamp\www\hunttheme\Hotaru.php:1724

    [21-Apr-2015 04:04:59 Europe/Paris] PHP 5. Libs\AdminPages->maintenanceAction() C:\wamp\www\hunttheme\libs\AdminPages.php:62

    [21-Apr-2015 04:04:59 Europe/Paris] PHP 6. Libs\Hotaru->generateReport() C:\wamp\www\hunttheme\libs\AdminPages.php:320

    [21-Apr-2015 04:04:59 Europe/Paris] PHP 7. Libs\Debug->generateReport() C:\wamp\www\hunttheme\Hotaru.php:1655

    [21-Apr-2015 04:04:59 Europe/Paris] PHP 8. Libs\Hotaru->openLog() C:\wamp\www\hunttheme\libs\Debug.php:227

    [21-Apr-2015 04:04:59 Europe/Paris] PHP 9. Libs\Debug->openLog() C:\wamp\www\hunttheme\Hotaru.php:1619

    [21-Apr-2015 04:04:59 Europe/Paris] PHP 10. filesize() C:\wamp\www\hunttheme\libs\Debug.php:162
     
  13. valMETNG

    valMETNG Administrator Staff Member Admin

    Unfortunately, I cannot troubleshoot from this stack trace because none of it refers to any of the files in the post_images plugin. Can you turn off your custom stack trace error reporting and just let normal error reporting occur?
     
  14. sereban

    sereban Active Member

    No errors. May be outdated Submit interferes, it does not have a Javascript folder for summernote.
     
  15. valMETNG

    valMETNG Administrator Staff Member Admin

    Even though you deleted summernote and the Javascript folder, that should not impact post_images.

    It appears from your error messages that you're running your environment locally. If you load your build onto a host that allows me to login, you can message me credentials and I can take a look. It works in my pure/base Hotaru build, my customized development build, and my production environment, so there must be something specific in your environment that's blocking it.
     
  16. shibuya246

    shibuya246 Hotaru Developer Staff Member Admin

    valMETNG likes this.
  17. cecilporter

    cecilporter Donor Donor

    I'm getting a CSRF error when I try to add an image to an existing post.

    Hotaru CMS v 1.7.3
    PHP v 5.4.42
    Post Images 1.8
     
  18. valMETNG

    valMETNG Administrator Staff Member Admin

    @shibuya246: want to try out your recent CSRF work here?
     
  19. UncleDanger

    UncleDanger New Member

    This is an absolutely awesome plugin. It's literally my first day with Hotaru and I can't believe how great everything works!

    But of course, I have a problem. Currently, the thumbnail displays to the right, which is perfect, but the text doesn't wrap around it:

    upload_2016-6-8_20-4-3.png

    This is how I'd rather it looked:

    upload_2016-6-8_20-7-33.png

    Is that possible, do you think?
     
  20. valMETNG

    valMETNG Administrator Staff Member Admin

    Welcome to Hotaru. Please PM me the URL of this AMD post and I can take a look at the css and see what the problem is. Bootstrap has gone through many upgrades since this plugin came out so it's likely just a small conflict in css that we can resolve quickly.
     

Share This Page