Wordpress에서 컨텐트 편집자가 이미지를 게시물에 업로드 할 때 "전체 크기"옵션을 선택하지 못하게 할 방법이 있습니까? "축소판", "중간"및 "큰"옵션 만 갖기를 바랍니다. 나는 이것을하기 위해 가위 플러그인을 사용했지만, Wordpress 2.9에서는이 플러그인이 더 이상 작동하지 않습니다.Wordpress 사용자가 전체 크기 이미지 업로드를 허용하지 못하도록
답변
WordPress에서 전체 크기 옵션을 표시하지 않아도이 결과를 얻을 수 있습니다. 크기 라디오 버튼을 만드는 함수는 wp-admin/includes/media.php
이고 image_size_input_fields
이라고합니다.
알고있는 함수에 대한 필터 또는 액션 훅은 없지만 필터를 호출하는 함수 (image_attachment_fields_to_edit
)의 필터 훅은 attachment_fields_to_edit
입니다.
기본적으로 필터 훅을 사용하여이 두 함수를 재정의 할 수 있습니다.
표준 functions.php 파일에서 작동하거나 플러그인에 통합 할 수 있다고 가정합니다. 우리는 우리의 두 가지 기능을 만들
add_filter('attachment_fields_to_edit', 'MY_image_attachment_fields_to_edit', 11, 2);
다음 :
첫째, 새로운 필터를 추가 할 수 있습니다. 난 그냥이 사건에 대한 MY_
로 이름을 접두어로했습니다
function MY_image_attachment_fields_to_edit($form_fields, $post) {
if (substr($post->post_mime_type, 0, 5) == 'image') {
$alt = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
if (empty($alt))
$alt = '';
$form_fields['post_title']['required'] = true;
$form_fields['image_alt'] = array(
'value' => $alt,
'label' => __('Alternate text'),
'helps' => __('Alt text for the image, e.g. “The Mona Lisa”')
);
$form_fields['align'] = array(
'label' => __('Alignment'),
'input' => 'html',
'html' => image_align_input_fields($post, get_option('image_default_align')),
);
$form_fields['image-size'] = MY_image_size_input_fields($post, get_option('image_default_size', 'medium'));
} else {
unset($form_fields['image_alt']);
}
return $form_fields;
}
일반 워드 프레스 함수에서 여기 변경된 유일한 것은 우리가 대신 image_size_input_fields
의 MY_image_size_input_fields
를 호출하고 있다는 점이다. 실제 숨어 않습니다
이제 기능 : 두 가지 변경이 마지막 기능에서
function MY_image_size_input_fields($post, $check = '') {
// get a list of the actual pixel dimensions of each possible intermediate version of this image
/* $size_names = array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full size')); */
$size_names = array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'));
if (empty($check))
$check = get_user_setting('imgsize', 'medium');
echo '<pre>'; print_r($check); echo '</pre>';
foreach ($size_names as $size => $label) {
$downsize = image_downsize($post->ID, $size);
$checked = '';
// is this size selectable?
$enabled = ($downsize[3] || 'large' == $size);
$css_id = "image-size-{$size}-{$post->ID}";
// if this size is the default but that's not available, don't select it
if ($size == $check) {
if ($enabled)
$checked = " checked='checked'";
else
$check = '';
} elseif (!$check && $enabled && 'thumbnail' != $size) {
// if $check is not enabled, default to the first available size that's bigger than a thumbnail
$check = $size;
$checked = " checked='checked'";
}
$html = "<div class='image-size-item'><input type='radio' " . ($enabled ? '' : "disabled='disabled' ") . "name='attachments[$post->ID][image-size]' id='{$css_id}' value='{$size}'$checked />";
$html .= "<label for='{$css_id}'>$label</label>";
// only show the dimensions if that choice is available
if ($enabled)
$html .= " <label for='{$css_id}' class='help'>" . sprintf(__("(%d × %d)"), $downsize[1], $downsize[2]). "</label>";
$html .= '</div>';
$out[] = $html;
}
return array(
'label' => __('Size'),
'input' => 'html',
'html' => join("\n", $out),
);
}
. 맨 위에서 $ size_names 배열 정의에서 '전체 크기'에 대한 참조를 제거합니다. 그런 다음 $enabled = ($downsize[3] || 'large' == $size);
라고 표시된 행이 변경되었습니다. 'full' == $size
을 'large' == $size
으로 바 꾸었습니다. 나는 큰 크기를 사용하지 않도록 찾는 게 아니에요
큰 크기를 비활성화 할 수는 없지만 너비와 높이를 중간 크기와 같게 설정할 수는 있습니다. 설정 아래에 있습니다 → 미디어
:
다음은 결과의 스크린 샷입니다. 난 그냥 크기를 조정하지 않고 기본적으로 이미지를 "있는 그대로"삽입하는 전체 크기를 비활성화하려고합니다. 그리고 이것에 대한 상한을 정할 수있는 것처럼 보이지 않습니다. – Kyle
- 1. URL을 기반으로 한 wordpress 이미지 크기
- 2. Proftpd가 전체 업로드를 확인합니다
- 3. 전체 화면 배경 이미지 크기 조정
- 4. Wordpress - 색인 페이지 이미지 크기 조정
- 5. 향상된 WYSIWYG 이미지 크기 조정을위한 Wordpress 플러그인?
- 6. 이전의 모든 WordPress 이미지 크기 조정
- 7. CDN을 사용하여 사용자 이미지 업로드를 저장/제공합니까?
- 8. 사용자가 100MB 업로드를 처리하는 방법
- 9. webview의 직접 이미지 링크 전체 크기 표시
- 10. iphone 전체 화면 크기 조정 이미지 미리보기
- 11. 전체 화면 크기 조정 배경 이미지 오버레이
- 12. 사용자가 Excel 인스턴스를 사용하지 못하도록
- 13. 사용자가 SVN에서 파일을 커밋하지 못하도록
- 14. Sharepoint에서 사용자가 기능을 활성화하지 못하도록
- 15. 사용자가 입력란에서 입력하지 못하도록 하시겠습니까?
- 16. 사용자가 로그를 보지 못하도록 PHP
- 17. 전체 크기 테두리보기
- 18. Wordpress에서 다른 이미지 크기
- 19. 이미지 크기 및 PHP 업로드
- 20. 파일 업로드를 사용하여 메모리의 이미지 표시
- 21. WordPress 이미지 테두리
- 22. 사용자가 미래 날짜를 입력하거나 선택하지 못하도록 막으십시오.
- 23. SWT의 텍스트 필드에 사용자가 문자를 입력하지 못하도록
- 24. 사용자가 비디오 모드로 전환하지 못하도록 제한하십시오.
- 25. 여러 사용자가 추천 시스템을 사용하지 못하도록 막으십시오.
- 26. FB 사용자가 앱을 사용하지 못하도록 차단하십시오.
- 27. std :: vector가 push_back에서 크기 조정하지 못하도록 함
- 28. Wordpress 테마 : 새로 만든 미리보기 이미지 크기 강제 생성
- 29. 안드로이드 크기 조정 이미지
- 30. MySQL이 쿼리에서 전체 테이블 스캔을 사용하지 못하도록
감사합니다! 이것은 내가 원하는 것입니다! – Kyle