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.
@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.
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
@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
@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.
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)) {
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*/
- 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 { ..........
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 ?
Comments
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
http://gitorious.org/statusnet/
in Notice.php
$notice->rendered = common_render_content($final, $notice);//hack code hereif (!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>';}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.
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'
I just push all my hack work to http://gitorious.org/hack-of-statusnet.
any one can help me to optimize the code?
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
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">
'" 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.. =)
- 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? =)
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();
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