Skip to content

【RSS】サムネイル画像の表示条件を変更してはどうか #777

Open
@inc2734

Description

@inc2734
// first img
if ( ! $thumbnail ) {
	$description = $args['_item']->get_description();
	if ( preg_match( '|^(?:<a [^>]+?>)?(<img [^>]+?>)|ims', $description, $match ) ) {
		$thumbnail = $match[1];
		$thumbnail = preg_replace( '|style="[^"]*?"|', '', $thumbnail );
		$thumbnail = preg_replace( '|class="[^"]*?"|', '', $thumbnail );
	}
}

// first img
if ( ! $thumbnail ) {
	$content = $args['_item']->get_content();
	if ( $content && preg_match( '|<img [^>]+?>|ims', $content, $match ) ) {
		$thumbnail = $match[0];
		$thumbnail = preg_replace( '|style="[^"]*?"|', '', $thumbnail );
		$thumbnail = preg_replace( '|class="[^"]*?"|', '', $thumbnail );
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions