X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Foembed.php;h=0d8be55656a0899c80cd0ac6d87c654a468a245f;hb=59a0b2a82da418f688faf182407146d9e7a7af7a;hp=da3aa0c716c8d313881cc5bc1ec8c1e22a6b1c8a;hpb=5b94d9e86b91707a47b143482775acad8fcf9e78;p=quix0rs-gnu-social.git diff --git a/actions/oembed.php b/actions/oembed.php index da3aa0c716..0d8be55656 100644 --- a/actions/oembed.php +++ b/actions/oembed.php @@ -61,7 +61,7 @@ class OembedAction extends Action $proxy_args = $r->map($path); if (!$proxy_args) { - $this->serverError(_("$path not found."), 404); + $this->serverError(sprintf(_('"%s" not found.'),$path), 404); } $oembed=array(); $oembed['version']='1.0'; @@ -73,7 +73,7 @@ class OembedAction extends Action $id = $proxy_args['notice']; $notice = Notice::staticGet($id); if(empty($notice)){ - $this->serverError(_("Notice $id not found."), 404); + $this->serverError(sprintf(_("Notice %s not found."),$id), 404); } $profile = $notice->getProfile(); if (empty($profile)) { @@ -92,7 +92,7 @@ class OembedAction extends Action $id = $proxy_args['attachment']; $attachment = File::staticGet($id); if(empty($attachment)){ - $this->serverError(_("Attachment $id not found."), 404); + $this->serverError(sprintf(_('Attachment %s not found.'),$id), 404); } if(empty($attachment->filename) && $file_oembed = File_oembed::staticGet('file_id', $attachment->id)){ // Proxy the existing oembed information @@ -108,10 +108,23 @@ class OembedAction extends Action $oembed['url']=$file_oembed->url; }else if(substr($attachment->mimetype,0,strlen('image/'))=='image/'){ $oembed['type']='photo'; - //TODO set width and height - //$oembed['width']= - //$oembed['height']= + if ($attachment->filename) { + $filepath = File::path($attachment->filename); + $gis = @getimagesize($filepath); + if ($gis) { + $oembed['width'] = $gis[0]; + $oembed['height'] = $gis[1]; + } else { + // TODO Either throw an error or find a fallback? + } + } $oembed['url']=$attachment->url; + $thumb = $attachment->getThumbnail(); + if ($thumb) { + $oembed['thumbnail_url'] = $thumb->url; + $oembed['thumbnail_width'] = $thumb->width; + $oembed['thumbnail_height'] = $thumb->height; + } }else{ $oembed['type']='link'; $oembed['url']=common_local_url('attachment', @@ -120,7 +133,7 @@ class OembedAction extends Action if($attachment->title) $oembed['title']=$attachment->title; break; default: - $this->serverError(_("$path not supported for oembed requests."), 501); + $this->serverError(sprintf(_('"%s" not supported for oembed requests.'),$path), 501); } switch($args['format']){ case 'xml': @@ -202,4 +215,15 @@ class OembedAction extends Action return; } + /** + * Is this action read-only? + * + * @param array $args other arguments + * + * @return boolean is read only action? + */ + function isReadOnly($args) + { + return true; + } }