●画像の回り込み
画像の回り込みのカスタマイズに挑戦しました。
画像のUP時に、回り込みを右にするか左にするのかを選択できる方法です。
参考サイトJuanlog: MovableType 画像回り込み改造
続きを読む
- 「upload_complete.tmpl」(tmpl/cms/)の書き換え
※必ずバックアップを作製する事!!
- 209行辺り
<td align="right" valign="top" colspan="3"><font class="instructional"><input type="checkbox" name="constrain" value="1" checked> <MT_TRANS phrase="Constrain proportions"></td> </tr> </table>
↓(書き換え)
<td align="right" valign="top" colspan="3"><font class="instructional"><input type="checkbox" name="constrain" value="1" checked> <MT_TRANS phrase="Constrain proportions"></td> </tr> <tr> <td>Image floating:</td> <td ><select name="ifloat" class="menu" > <option value="left" selected>left <option value="right" >right <option value="none">none </select></td> </tr> </table> - 20行くらい下
<input class="button-big" type="button" onClick="doClick(this.form, 'popup=1&width=<TMPL_VAR NAME=WIDTH>&height=<TMPL_VAR NAME=HEIGHT>&image_type=<TMPL_VAR NAME=IMAGE_TYPE>')" value="<MT_TRANS phrase="Popup Image">"> <input class="button-big" type="button" onClick="doClick(this.form, 'nclude=1&width=<TMPL_VAR NAME=WIDTH>&height=<TMPL_VAR NAME=HEIGHT>&image_type=<TMPL_VAR NAME=IMAGE_TYPE>')" value="<MT_TRANS phrase="Embedded Image">">
↓(書き換え)
<input class="button-big" type="button" onClick="doClick(this.form, 'imgfloat='+this.form.ifloat.value+'&popup=1&width=<TMPL_VAR NAME=WIDTH>&height=<TMPL_VAR NAME=HEIGHT>&image_type=<TMPL_VAR NAME=IMAGE_TYPE>')" value="<MT_TRANS phrase="Popup Image">"> <input class="button-big" type="button" onClick="doClick(this.form, 'imgfloat='+this.form.ifloat.value+'&include=1&width=<TMPL_VAR NAME=WIDTH>&height=<TMPL_VAR NAME=HEIGHT>&image_type=<TMPL_VAR NAME=IMAGE_TYPE>')" value="<MT_TRANS phrase="Embedded Image">">
- 209行辺り
- 「CMS.pm」の書き換え
- 1365行くらい
if ($q->param('popup')) { require MT::Template; if (my $tmpl = MT::Template->load({ blog_id => $blog_id, type => 'popup_image' })) { (my $base = $q->param('fname')) =~ s!\.[^.]*$!!; if ($base =~ m!\.\.|\0|\|!) { return $app->error($app->translate( "Invalid basename '[_1]'", $base)); }
↓(書き換え)
my $imgclass; if ($q->param('imgfloat') eq 'left') { $imgclass = " class='l' "; }elsif ($q->param('imgfloat') eq 'right') { $imgclass = " class='r' "; }else { $imgclass = ''; } if ($q->param('popup')) { require MT::Template; if (my $tmpl = MT::Template->load({ blog_id => $blog_id, type => 'popup_image' })) { (my $base = $q->param('fname')) =~ s!\.[^.]*$!!; if ($base =~ m!\.\.|\0|\|!) { return $app->error($app->translate( "Invalid basename '[_1]'", $base)); } - 50行くらい下
my $link = $thumb ? qq(<img $imgclass src="$thumb" width="$thumb_width" height="$thumb_height" border="0" />) : "View image"; return <<HTML; <a href="$url" onclick="window.open('$url','popup','width=$width,height=$height,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false">$link</a> HTML } elsif ($q->param('include')) { (my $fname = $url) =~ s!^.*/!!; if ($thumb) { return <<HTML; <a href="$url"><img $imgclass alt="$fname" src="$thumb" width="$thumb_width" height="$thumb_height" border="0" /></a> HTML } else { return <<HTML; <img alt="$fname" $imgclass src="$url" width="$width" height="$height" border="0" />
↓(書き換え)
my $link = $thumb ? qq(<img $imgclass src="$thumb" width="$thumb_width" height="$thumb_height" border="0" />) : "View image"; return <<HTML; <a href="$url" onclick="window.open('$url','popup','width=$width,height=$height,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false">$link</a> HTML } elsif ($q->param('include')) { (my $fname = $url) =~ s!^.*/!!; if ($thumb) { return <<HTML; <a href="$url"><img $imgclass alt="$fname" src="$thumb" width="$thumb_width" height="$thumb_height" border="0" /></a> HTML } else { return <<HTML; <img alt="$fname" $imgclass src="$url" width="$width" height="$height" border="0" />
- 1365行くらい
- 「styles-site.css」に付け加える
img.r {
float: right;
border: none;
margin-right:4px;
margin-top:4px;
vertical-align:top;
}
img.l {
float: left;
border: none;
margin-right:4px;
margin-top:4px;
vertical-align:top;
}
元に戻す