【Blogger/QooQ】注目記事:画像なし記事にデフォルトサムネイル画像を表示

2020-12-22

Blogger プログラミング

B!

ちなみにガジェットの追加/削除、設定変更を行うとコードがリセットされますので再度編集してください。
移動だけではリセットされません。


フリーのBloggerテンプレート「QooQ」のカスタマイズについてまとめています。
参考程度に。

尚、カスタマイズはバックアップを取った上、自己責任で行うようにしてください。





CSSの追加

で解説した方法の注目記事(最新記事)ガジェットVer.ですので悪しからず。

クラス「post-summary-img-contents」を増やしました。
名前はお好きに。

元のcss

/* *****************************************************************************
		注目の投稿 ガジェット
***************************************************************************** */
.post-summary a {
	color			: $(font.color) !important;
}

修正後のcss

/* *****************************************************************************
		注目の投稿 ガジェット
***************************************************************************** */
.post-summary a {
	color			: $(font.color) !important;
}
.post-summary-img-contents {
	position				: relative;
	width					: 100%;
	min-width				: 100%;
}
.post-summary-img-contents:before {
	content					: "";
	display					: block;
	padding-top				: 50%;
}
.post-summary-img-contents div {
	background-image		: url("画像のurl");
	background-repeat		: no-repeat;
	background-size			: contain;
	position				: absolute;
	top						: 0;
	left					: 0;
	bottom					: 0;
	right					: 0;
	width					: 100%;
}

htmlの変更

例のごとく分岐<b:else/>の追加、<div>で追加したクラスを指定。

元のhtml

	<div class='post-summary'>
		<a expr:href='data:postUrl'>
			<b:if cond='data:showFirstImage and data:postFirstImage != &quot;&quot;'>
				<img class='image' expr:src='data:postFirstImage'/>
			</b:if>
			<b:if cond='data:showPostTitle and data:postTitle != &quot;&quot;'>
				<h3><data:postTitle/></h3>
			</b:if>
			<b:if cond='data:showSnippet and data:postSummary != &quot;&quot;'>
				<p><data:postSummary/></p>
			</b:if>
		</a>
	</div>

修正後のhtml

	<div class='post-summary'>
		<a expr:href='data:postUrl'>
			<b:if cond='data:showFirstImage and data:postFirstImage != &quot;&quot;'>
				<img class='image' expr:src='data:postFirstImage'/>
			<b:else/>
				<div class='post-summary-img-contents'><div/></div>
			</b:if>

			<b:if cond='data:showPostTitle and data:postTitle != &quot;&quot;'>
				<h3><data:postTitle/></h3>
			</b:if>

			<b:if cond='data:showSnippet and data:postSummary != &quot;&quot;'>
				<p><data:postSummary/></p>
			</b:if>
		</a>
	</div>



ブログランキング・にほんブログ村へ

Translate

魔王と愉快な仲間

このブログを検索

ラベル

Blogger (7) FX (1) GAS (12) Utility (1) ゲーム (1) ツール (8) ファッション (5) プログラミング (18) まとめ (5) レポート (2) 移住 (3) 育て方 (29) 果菜 (14) 花菜 (2) 覚書 (1) 金策 (9) 茎菜 (3) 根菜 (4) 手法 (1) 多肉 (1) 土壌 (2) 独り言 (2) 読み物 (22) 農業 (3) 農薬 (1) 葉菜 (5)

ブログ アーカイブ

メッセージ

名前

メール *

メッセージ *

Powered by Blogger.

フリー写真素材ぱくたそ

QooQ