mediaãã©ã°ã¤ã³å¿ç¨(6) Viewãã¼ãã®è¨å®
mediaãã©ã°ã¤ã³ã®ãã«ãã¼Mediumã¨ãç·¨éãã©ã¼ã åºåç¨ã¨ã¬ã¡ã³ãAttachmentã®è¨å®ãå¤æ´ããã主ãªå¤æ°/å¼æ°ãã¾ã¨ãã¾ããã
Mediumãã«ãã¼
embed($path, $options)
- $path
ã表示ãã¡ã¤ã«ã®ãã¹ã
- $options
- $options['alt']
ã¿ã°ã®altè¦ç´ ãæå®ã
-
- $options['url']
æå®ã®URLã«ãªã³ã¯ããã
Htmlãã«ãã¼ã®link()ã¡ã½ããã使ç¨ãã¦ããã®ã§ãURLã®æå®æ¹æ³ã¯ãã¡ããåç
§ã
ãã ãã$htmlAttributes, $confirmMessage, $escapeTitleã®å±æ§ãåºå®ã«ãªãã®ã§èªç±åº¦ãä¸ããã
-
- $options['restrict']
æå®ã¨ç°ãªã種é¡ã®ãã¡ã¤ã«ã®å ´åãä½ãåºåããªãã
æå®æ¸å¼ã¯ããã©ã°ã¤ã³ã®vendor/medium/medium.phpã«è¨è¼ã®$_mimeTypesToNamesãã (Imageã¨ãï¼é¸ã¹ã°OK
static $_mimeTypesToNames = array( 'application/ogg' => 'Audio', 'application/pdf' => 'Document', 'application/msword' => 'Document', 'image/icon' => 'Icon', 'text/css' => 'Css', 'text/javascript' => 'Js', 'text/code' => 'Generic', 'text/rtf' => 'Document', 'text/plain' => 'Text', 'image/' => 'Image', 'audio/' => 'Audio', 'video/' => 'Video', 'text/' => 'Generic', '/' => 'Generic', );
-
- $options['id'],$options['class']
åºåã¿ã°ã®IDã¨classãæå®ã
-
- $options['width'],$options['height']
åºåã¿ã°ã®widhtã¨heightè¦ç´ ãæå®ã
ç»åãåç»ã®å ´åãåå¾ã§ããã°èªåæå®ãããã
-
- $options['autoplay'],$options['controls'],$options['background']
åç»ã®å ´åãèªååçãããã»åç»åçã®ã³ã³ããã¼ã«ããã«åºåã»èæ¯è²ãªã©ãæå®ãããªãã·ã§ã³ãåç»ã®ç¨®é¡ã«ãã£ã¦ã¯ç¡å¹ãªå ´åããã
file($path, $Attachment)
ãæå®ãã¡ã¤ã«ã®ãã¹ãè¿ãã¡ã½ããã
ãfileã¡ã½ããã®å¼æ°ã¯æ¬æ¥$path1ã¤ã ãã§ãããfunc_get_args()ã使ã£ã¦ç¬¬äºå¼æ°ã®å¦çãè¡ãªã£ã¦ãã¾ããattachmentsããåå¾ãããã¼ã¿ãããã«æå®ãã¾ãã
- $path
ãfilter/sãã®ããã«ãVersionãã¡ã¤ã«ã®ãã£ã¬ã¯ããª/è¨å®ãæå®ã
Viewã®è¨è¼ä¾(ã¢ãããã¼ãæ¸ã¿ç»åã®è¡¨ç¤º)
$path = $upfile->file( 'filter/m', $user['Attachment'][0] ); $url = null; if ($user['User']['id'] == $target_user['User']['id']) { $url = array( 'controller' => 'users', 'action' => 'edit_image', ); } echo $medium->embed( $path, $options = array( 'url' => $url, 'alt' => $target_user['User']['name'], 'id' => 'HomeUserImage', 'restrict' => array('image') ) );
Attachment
ã¨ã¬ã¡ã³ããä»ã®ã¢ãã«ã®ç·¨éãã©ã¼ã ã«çµã¿è¾¼ãã§ãæ·»ä»ãã¡ã¤ã«ã®ã¢ãããã¼ãã»åé¤ãã©ã¼ã ã表示ããã
å¤æ°
- $previewVersion
ã¢ãããã¼ãæ¸ã¿ç»åã®è¡¨ç¤ºãµã¤ãºãæå®ãªãå ´åxxs
- $assocAlias
ã¢ãããã¼ããã¡ã¤ã«ã®ã¢ãã«åãæå®ãæå®ããªãå ´åAttachmentã
ãããå¤æ´ãã¦ãImage, Video, Documentã»ã»ã»ã®ããã«ããã¨ãç»åã»åç»ã»æç« ãå¥ã
ã«ä¿ç®¡ã§ãããä½ãããããã«ã¢ãã«ã®è¨å®ã¨ã³ã³ããã¼ã©å¦çãå¿
è¦ã
- $model
ã¢ãããã¼ããã¡ã¤ã«ã®è¦ªã¢ãã«ãæå®ããªãå ´åãç¾å¨ã®ã¢ãã«ã
Viewã®è¨è¼ä¾(ç·¨éç»é¢ã«ãã©ã¼ã 追å )
<?php echo $form->create('User', array( 'url' => array( 'controller' => 'users', 'action' => 'edit', $user['id'] ), 'type' => 'file', ));?> (ä¸ç¥ï¼ echo $this->element( 'attachments', $options => array( 'plugin' => 'media', 'previewVersion' => 'm', ) );