{"id":233106,"date":"2023-02-05T10:44:00","date_gmt":"2023-02-05T07:44:00","guid":{"rendered":"https:\/\/wordpress.mediadoma.com\/?p=233106"},"modified":"2023-02-05T10:48:15","modified_gmt":"2023-02-05T07:48:15","slug":"kuinka-sallia-kuvat-url-osoitteen-sijasta-wordpress-kommenteissa","status":"publish","type":"post","link":"https:\/\/wordpress.mediadoma.com\/fi\/kuinka-sallia-kuvat-url-osoitteen-sijasta-wordpress-kommenteissa\/","title":{"rendered":"Kuinka sallia kuvat URL-osoitteen sijasta WordPress-kommenteissa?"},"content":{"rendered":"<p>Oletuksena kommentin URL-osoitteet s\u00e4ilytet\u00e4\u00e4n sellaisina kuin ne ovat. Jos k\u00e4ytt\u00e4j\u00e4 laittaa suoraan kuvan URL-osoitteen, olisi mukava korvata URL-osoite varsinaisella HTML img -tunnisteella. Lis\u00e4\u00e4 seuraava <a href=\"https:\/\/wordpress.mediadoma.com\/fi\/kuinka-tallentaa-wechat-token-vaelimuistiin-php-n-kautta\/\" title=\"PHP-koodinp\u00e4tk\u00e4\">PHP-koodinp\u00e4tk\u00e4<\/a> wordpress <a href=\"https:\/\/helloacm.com\/how-to-remove-product-review-in-woocommercewordpress\/\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">&#8211;<\/a> teemaan <a href=\"https:\/\/helloacm.com\/how-to-remove-admin-topbar-in-wordpress\/\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">functions.php<\/a> :<\/p>\n<pre><code>\/\/ empty - allow all posts, otherwise, put post IDs joined by comma\ndefine('ALLOW_POSTS', '');\nfunction helloacm_allow_comment_image( $comment) {\n\u00a0 \u00a0 $post_ID = $comment[\"comment_post_ID\"];\n\u00a0 \u00a0 $allow_posts = ALLOW_POSTS? explode(',', ALLOW_POSTS): array();\n\u00a0 \u00a0 if(empty($allow_posts) || in_array($post_ID, $allow_posts)){\n\u00a0 \u00a0 \u00a0 \u00a0 global $allowedtags;\n\u00a0 \u00a0 \u00a0 \u00a0 $content = $comment[\"comment_content\"];\n\u00a0 \u00a0 \u00a0 \u00a0 $content = preg_replace('\/(https?:\/\/S+.(?:jpg|png|jpeg|gif|bmp))+\/','&lt;img \u00a0title=\"$0 How to Allow Images Instead of URL in WordPress Comments? wordpress \" src=\"$0\" \u00a0alt=\"$0 How to Allow Images Instead of URL in WordPress Comments? wordpress \" \u00a0\/&gt;',$content);\n\u00a0 \u00a0 \u00a0 \u00a0 $allowedtags['img'] = array('src' =&gt; array(), 'alt' =&gt; array());\n\u00a0 \u00a0 \u00a0 \u00a0 $comment[\"comment_content\"] = $content;\n\u00a0 \u00a0 }\n\u00a0 \u00a0 return $comment;\n}\nadd_filter('preprocess_comment', 'helloacm_allow_comment_image');<\/code><\/pre>\n<p>K\u00e4yt\u00e4mme s\u00e4\u00e4nn\u00f6llist\u00e4 lauseketta kuvien URL-osoitteiden etsimiseen (p\u00e4\u00e4ttyy jpg\/png\/jpeg\/gif\/bmp) ja korvaamme sen HTML-img-tunnisteella. Meid\u00e4n on my\u00f6s sallittava IMG-tunniste kommenttiosiossa, jotta se n\u00e4kyy oikein. Yll\u00e4 oleva funktio on lis\u00e4tt\u00e4v\u00e4 suodattimeen preprocess_comment, joka vedet\u00e4\u00e4n ennen kommentin lis\u00e4\u00e4mist\u00e4 <a href=\"https:\/\/helloacm.com\/easy-round-robin-scheduled-database-backup-on-linux\/\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">tietokantaan<\/a>.<\/p>\n<p><div id=\"PostUnique_PostSource\" style=\"padding-top: 50px\">:  <a target=\"_blank\" rel=\"noopener nofollow\" href=\"\/\/helloacm.com\" class=\"external external_icon\">helloacm.com<\/a><\/div><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Kuinka sallia kuvat URL-osoitteen sijasta WordPress-kommenteissa?<\/p>\n","protected":false},"author":1,"featured_media":224757,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_wp_rev_ctl_limit":""},"categories":[895,834,843,803,864],"tags":[1166],"class_list":["post-233106","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-koodi","category-opas-aloittelijoille","category-opetusohjelmia","category-php-5","category-wordpress-5","tag-affiai-fi"],"_links":{"self":[{"href":"https:\/\/wordpress.mediadoma.com\/fi\/wp-json\/wp\/v2\/posts\/233106","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.mediadoma.com\/fi\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress.mediadoma.com\/fi\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/fi\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/fi\/wp-json\/wp\/v2\/comments?post=233106"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.mediadoma.com\/fi\/wp-json\/wp\/v2\/posts\/233106\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/fi\/wp-json\/wp\/v2\/media\/224757"}],"wp:attachment":[{"href":"https:\/\/wordpress.mediadoma.com\/fi\/wp-json\/wp\/v2\/media?parent=233106"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/fi\/wp-json\/wp\/v2\/categories?post=233106"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/fi\/wp-json\/wp\/v2\/tags?post=233106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}