通常は修正できないテンプレート化されたコードを「ハック」するための小さなコード スニペットがあります。
<script>
jQuery( document ).ready(function() {
jQuery(".avatar").each(function() {
var text = jQuery(this).attr("src");
text = text.replace("-64x64.jpg", ".jpg");
text = text.replace("-80x80.jpg", ".jpg");
text = text.replace("-32x32.jpg", ".jpg");
text = text.replace("-28x28.jpg", ".jpg");
text = text.replace("-16x16.jpg", ".jpg");
text = text.replace("-128x128.jpg", ".jpg");
jQuery(this).attr("src", text);
});
});
</script>
上記のスクリプトをブラウザで実行すると、コンソールに次のエラーが表示されます。
TypeError: text is undefined
text = text.replace("-64x64.jpg", ".jpg");
頭を悩ませていますが、何も思いつきません。var text; を使用してみました。スクリプトの開始時にそれを試して定義し、何かと競合する場合に備えて別の変数名を使用しようとしましたが、どちらも何もしませんでした....