Post with image and videos

I want to show image/video attachments thumbnail with the post like facebook. How can I do that?
Is any plugin there to do this? Please help me.

Thanks in advance!!

Comments

  • I aslo want it. So I'm working on this plugin my own.
  • Hello smoothdvd,

    No plugin with feature at present?
    Are you almost success in it?
    can you please provide me the plugin details. I mean, then general idea how to proceed with it?
    or please upload it here.

    Thanks,
    Vipin
  • Great, you guys should get familiar with gitorious, so that you can contribute and collaborate with the SatusSet team!

    http://gitorious.org/statusnet/
  • Something like this i guess http://edno23.com/ you can see the thumbs for videos and pictures...
  • Well, with some overlay hidden, would be nice :) However is that a sliced thumb, or resized fullsize image ?
  • will ya share the hack ? with some additional css it can get quite pretty :)
  • @bedio, sure.

    in Notice.php
    $notice->rendered = common_render_content($final, $notice);
    //hack code here
    if (!empty($options['attach_image'])) {
    $file = $options['attach_image'];
    $notice->rendered .= '<a href="'.
    $file->shorturl().
    '" title="" target="_blank" class="attachment_thumb"><img src="http://'.
    common_config('site', 'server').'/'.common_config('site', 'path').'file/'.$file->filename_thumb.
    '" alt="" /></a>';
    }
  • Ok, I will do my best to style it a bit :) tonight, I guess....
  • me too, i will add gray borde with with white inner padding to image.
  • @bedio @smoothdvd i have just tried this hack on a test site and nothing happens. When you say that you must hack notice.php i assume that you are talking about the one in the classes folder. Secondly i have tried the putting all the lines in like they are displayed here and also tried putting them on different lines that make sense. There are no errors and i try and upload an image and nothing happens. Does this change the display on the public time line or does happen on the user's profile page? Also does this change the rendering in the database.

    Would it not make more sense to display it based on whether or not it is shown and change the code in the noticelist.php file round line 362?

    $this->out->elementStart('p', array('class' => 'entry-content'));
    if ($this->notice->rendered) {
    $this->out->raw($this->notice->rendered);

    Also because you can only upload 1 image at a time, would this not make more sense?
    http://twitgoo.com/16l1qx

    Please tell me what you are thinking as i would love this functionality and am definitely ready to help.
  • Sorry, there are many hacks to do, i will upload them to git
  • smoothdvd would you give us a link to the git, where the hack is ?
  • @bedio, @TweXXX Sorry to my lazy work:)

    I just push all my hack work to http://gitorious.org/hack-of-statusnet.

    the hack codes to show upload image's thumbnail in noticelist are following:

    lib/mediafile.php
    //add resize function to generate thumbnail and medium size of upload image
    var $filename_thumb = null;
    var $filename_small = null;
    var $filename_medium = null;
    var $type;
    var $height;
    var $width;

    and resize(), resize_x() etc. function

    action/newnotice.php
    //send attach_image with $option

    $options = $options + array('attach_image' => $upload);

    classes/Notice.php
    //add rendered html code to
    if (!empty($options['attach_image'])) {
    $file = $options['attach_image'];
    ...

    and last you can moidify js/util.js to add same overlay function to thumbnail image

    note: all hack code i made mark with 'Alex Gao'
  • @smoothdvd thanks for this. Will keep checking on this.
  • Thanks smoothdvd .
  • Anyone can synthesize this into a plugin ?
  • @smoothdvd. thank you for the fantastic job. it is working great!
  • @sam where did you get it?
  • @TweXXX

    I just push all my hack work to http://gitorious.org/hack-of-statusnet.

    any one can help me to optimize the code?
  • @smoothdvd Sorry, I don't understand how to see the code. Sorry haven't used gitorious before. I am more than willing to help with the code optimization.
  • @smoothdvd Sorry, I don't understand how to see the code. Sorry haven't used gitorious before. I am more than willing to help with the code optimization.
  • @TweXXX here is what I did to get code. I did register first.
    1. go to http://gitorious.org/hack-of-statusnet
    2. click "Source Tree"
    3 . find the four files @smoothdvd changed for this. they are lib/mediafile.php, actions/newnotice.php, classes/notice.php & js/util.js. search the Alex Gao in those files and copy the new/updated codes to my file
  • @sam @smoothdvd that works so well. will look into the code and see what can be changed and made better. very cool well done.
  • almost done with video 'thumbnail' preview!
  • @smoothdvd i have tested out the code and can't see anything wrong with it. The upload works well with large images and small images. The rendering in the normal site as well as the mobile site works well. Very well done.
  • This is great new. I just want to mention, that such modifications in the core of status.net would not be good for future updates (when new status.net versions come out), so this really should be a plugin, instead of edited core files.
  • @smoothdvd @sam @TweXXX @aric

    Excuse me... but it does not work for me..
    I only can post notice.. but without attachment.
    And when i use attachment, it do not appear at all.

    Please review my changes:

    - I use statusnet 0.9.4 -

    ** lib/mediafile.php (2 lines changed):
    (1) line 46 - 55:
    /* Modified by Alex Gao Start Here */
    var $filename_thumb = null;
    var $filename_small = null;
    var $filename_medium = null;
    var $type;
    var $height;
    var $width;
    /* Modified by Alex Gao End Here */

    function __construct($user = null, $filename = null, $mimetype = null/* Modified By Alex Gao*/, $filename_thumb = null, $filename_small = null, $filename_medium = null)

    (2) line 209 - 221:
    .. after code:
    if (isset($mimetype)) {

    $basename = basename($_FILES[$param]['name']);
    $filename = File::filename($user->getProfile(), $basename, $mimetype);
    $filepath = File::path($filename);

    $result = move_uploaded_file($_FILES[$param]['tmp_name'], $filepath);

    if (!$result) {
    throw new ClientException(_('File could not be moved to destination directory.'));
    return;
    }


    .. I put this code:
    /* Modified by Alex Gao Start Here */
    require_once 'MIME/Type/Extension.php';
    $mte = new MIME_Type_Extension();
    try {
    $ext = $mte->getExtension($mimetype);
    } catch ( Exception $e) {
    $ext = strtolower(preg_replace('/\W/', '', $mimetype));
    }
    $filename_thumb = MediaFile::resize(120, 0, 0, $width, $height, $filepath, 't', $type, $ext);
    $filename_small = MediaFile::resize(200, 0, 0, $width, $height, $filepath, 's', $type, $ext);
    $filename_medium = MediaFile::resize_x(480, 0, 0, $width, $height, $filepath, 'm', $type, $ext);
    /* Modified by Alex Gao End Here */


    ** action/newnotice.php
    start from line 188 - 214:
    // use browser data if checked; otherwise profile data
    if ($this->arg('notice_data-geo')) {
    $locOptions = Notice::locationOptions($this->trimmed('lat'),
    $this->trimmed('lon'),
    $this->trimmed('location_id'),
    $this->trimmed('location_ns'),
    $user->getProfile());
    } else {
    $locOptions = Notice::locationOptions(null,
    null,
    null,
    null,
    $user->getProfile());
    }

    $options = array_merge($options, $locOptions);
    }
    /*Modified by Alex Gao Start Here*/
    $options = $options + array('attach_image' => $upload);
    /*Modified by Alex Gao End Here*/

    $notice = Notice::saveNew($user->id, $content_shortened, 'web', $options);

    if (isset($upload)) {
    $upload->attachToNotice($notice);
    }


    ** classes/Notice.php
    ln // Handle repeat case , start from line 338 - 352 :

    if (!empty($rendered)) {
    $notice->rendered = $rendered;
    } else {
    $notice->rendered = common_render_content($final, $notice);
    /*Modified by Alex Gao Start Here*/
    if (!empty($options['attach_image'])) {
    $file = $options['attach_image'];
    $notice->rendered .= ' $file->shorturl().
    '" title="" target="_blank" class="attachment_thumb">image common_config('site', 'server').'/'.common_config('site', 'path').'file/'.$file->filename_thumb.
    '" alt="" />
    ';
    }
    /*Modified by Alex Gao End Here*/
    }


    ** js/util.js ----> i followed each changes that related to thumbnail function


    In my config.php:

    //$config['attachments']['file_quota'] = 5000000;
    //$config['attachments']['user_quota'] = 50000000;
    //$config['attachments']['monthly_quota'] = 15000000;
    $config['attachments']['uploads'] = true;
    //$config['attachments']['path'] = "/file/"; //ignored if site is private
    $config['attachments']['dir'] = INSTALLDIR . '/file/';

    //Avatar image file:
    $config['uploads']['avatar_quota'] = 102400; // max size in bytes


    Please your attention..

    Thank you.. =)

  • someone could help me to solve this problem?
  • you just grab this one: my hack work to http://gitorious.org/hack-of-statusnet.
  • i've tried it..
    - visit http://gitorious.org/hack-of-statusnet
    - click 'source tree'
    - replace file: lib/mediafile.php, actions/newnotice.php, classes/notice.php & js/util.js.

    and error:
    Warning: PHP5 set/get calls should match the case of the variable in /usr/local/lib/php/DB/DataObject.php on line 3742

    Warning: PHP5 set/get calls should match the case of the variable in /usr/local/lib/php/DB/DataObject.php on line 3742

    Warning: PHP5 set/get calls should match the case of the variable in /usr/local/lib/php/DB/DataObject.php on line 3742

    Warning: PHP5 set/get calls should match the case of the variable in /usr/local/lib/php/DB/DataObject.php on line 3742

    Warning: PHP5 set/get calls should match the case of the variable in /usr/local/lib/php/DB/DataObject.php on line 3742

    any suggest? =)
  • wew... after tried it for more than 7 times, i success.. ^_^
    many thanks to @smoothdvd for great hacks..

    here steps that i took, hope these could useful for everyone..

    - visit: http://gitorious.org/hack-of-statusnet
    - save 4 files (Row blob data):
    * lib/mediafile.php
    * actions/newnotice.php
    * classes/notice.php
    * js/util.js.

    - based on files that i grab from gitorious, i edit (add) my files:

    *** lib/mediafile.php:
    # line 46, add:
    var $filename_thumb = null;
    var $filename_small = null;
    var $filename_medium = null;
    var $type;
    var $height;
    var $width;

    # line 55, edit:
    function __construct($user = null, $filename = null, $mimetype = null/* Modified By Alex Gao*/, $filename_thumb = null, $filename_small = null, $filename_medium = null)

    # line 72, add:
    $info = @getimagesize($this->fileRecord->url);
    ......

    # line 207, add:
    $info = @getimagesize($_FILES[$param]['tmp_name']);
    .........

    # line 247, add:
    require_once 'MIME/Type/Extension.php';
    $mte = new MIME_Type_Extension();
    try { ..........

    # line 268 - 487 , add:
    static function resize($size, $x = 0, $y = 0, $w = null, $h = null, $filepath, $resizetype, $type, $ext)
    {..............

    # line 572 - end, add:
    if(!function_exists('imagecreatefrombmp')){
    ...........


    *** actions/newnotice.php:
    line 197, i add:
    $options = $options + array('trackback' => $this->trimmed('trackback'), 'trackbackurl' => $this->trimmed('trackbackurl'));
    $options = $options + array('attach_image' => $upload);


    *** classes/notice.php:
    # line 133:
    I edit: $count = preg_match_all ...

    # line 321:
    I add: if (!empty($options['trackback'])) { ....

    #line: 328:
    I add: if (!empty($options['attach_image'])) {....


    *** js/util.js:
    # line 313:
    i add:
    SN.U.NoticeWithAttachmentThumbnail($('#'+notice.id));

    # line 510 - 576 :
    I add: NoticeAttachmentThumbnails: function() { ....

    # line 842:
    I add: SN.U.NoticeAttachmentThumbnails();
  • @liu sorry, I have not tested it with 0.9.4
  • HI
    I replaced that 4 files :
    * lib/mediafile.php
    * actions/newnotice.php
    * classes/notice.php
    * js/util.js.
    but I've got an error :
    Warning: PHP5 set/get calls should match the case of the variable in /home/******/public_html/statusnet-0.9.5/extlib/DB/DataObject.php on line 3886

    I am using 0.9.5

    any help please ?

    Also would that hack show the thumbnail of videos when we paste the URL from youtube ?

    regards
    Thanks all
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID