如果用户没有自动生成的头像,我该如何回归到默认图像?
这是我的代码。
<?php
if ( is_user_logged_in() ) {
echo '<img class="avatar" src="'. wsl_get_user_custom_avatar ($current_user->ID) .'" alt="avatar"> Welcome '.$current_user->display_name.', Please help our community grow by liking and sharing! <br> <a class="logout" href="'. wp_logout_url() .'">Logout</a>'; }
else {
echo '<h2>1 Click Login</h2>';
}
?>
<?php do_action( 'wordpress_social_login' ); ?>
答案 0 :(得分:1)
这样的东西?将默认头像的路径更改为您喜欢的...
public class BufferedWritableFileByteChannel implements WritableByteChannel {
private static final int BUFFER_CAPACITY = 1000000;
private boolean isOpen = true;
private final OutputStream outputStream;
private final ByteBuffer byteBuffer;
private final byte[] rawBuffer = new byte[BUFFER_CAPACITY];
public BufferedWritableFileByteChannel(OutputStream outputStream) {
this.outputStream = outputStream;
this.byteBuffer = ByteBuffer.wrap(rawBuffer);
}
@Override
public int write(ByteBuffer inputBuffer) throws IOException {
int inputBytes = inputBuffer.remaining();
if (inputBytes > byteBuffer.remaining()) {
dumpToFile();
byteBuffer.clear();
if (inputBytes > byteBuffer.remaining()) {
throw new BufferOverflowException();
}
}
byteBuffer.put(inputBuffer);
return inputBytes;
}
@Override
public boolean isOpen() {
return isOpen;
}
@Override
public void close() throws IOException {
dumpToFile();
isOpen = false;
}
private void dumpToFile() {
try {
outputStream.write(rawBuffer, 0, byteBuffer.position());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}