Ich suche nach einer Möglichkeit, dem Medien-Uploader ein -Menü hinzuzufügen, das zwei Optionen hat: normales Bild, das nichts tut, und Profilbild, das dem Bild eine CSS-class hinzufügt, wenn es ausgewählt ist.
Ich bin so weit gekommen, das Auswahlmenü dem Uploader hinzuzufügen, aber ich weiß nicht wie:
Das habe ich bisher:
function my_profile_image_select( $form_fields, $post ) { $form_fields['image-type'] = array( 'label' => 'Image Type', 'input' => 'html', 'helps' => 'Enter "profile-image" to enable profile image caption', ); $profile_image = 'profile-image'; $normal_image = 'normal-image'; $form_fields['image-type']['html'] = ''; $form_fields['image-type']['html'] .= 'Normal Image'; $form_fields['image-type']['html'] .= 'Profile Image'; $form_fields['image-type']['html'] .= ''; return $form_fields; } add_filter( 'attachment_fields_to_edit', 'my_profile_image_select', 10, 2 );
Um die class anzuwenden, benötigen Sie eine benutzerdefinierte function, um etwas mit dem Wert Ihrer Einstellung zu tun.
Um sicherzustellen, dass die ausgewählten Aufenthalte ausgewählt sind, verwenden Sie die function WP selected ()
$form_fields['image-type']['html'] = "';