我想为我在博客上写的每一篇文章附上一个ZIP文件。
我想找到一个插件来完成这些事情:
1-Insert on the post editor 这样的一个盒子可以让我上传文件。
2-自动插入at the bottom of each post 一个允许读者下载我附加的文件的框。
我想为我在博客上写的每一篇文章附上一个ZIP文件。
我想找到一个插件来完成这些事情:
1-Insert on the post editor 这样的一个盒子可以让我上传文件。
2-自动插入at the bottom of each post 一个允许读者下载我附加的文件的框。
我仍然会使用WordPress上传程序,但您需要修改它才能正常工作。假设您想要gpx文件(假设this 就是你的意思)。
当你上传东西时,WordPress会查看它的文件扩展名,并根据一组允许的mime类型,让上传通过或阻止它。这些允许的mime类型由函数获取get_allowed_mime_types
与WordPress中的几乎所有内容一样,它提供了一个过滤器来修改内容。upload_mimes
在这种情况下。
我们可以加入并允许.gpx
文件。Mime类型在的关联数组中指定regex_pattern => mime_type
总体安排
因此,要添加gpx:
<?php
add_filter(\'upload_mimes\', \'wpse66651_allow_gpx\');
/**
* Allow the uploading of .gpx files.
*
* @param array $mimes The allowed mime types in file extension => mime format
* @return array
*/
function wpse66651_allow_gpx($mimes)
{
$mimes[\'gpx\'] = \'application/xml\';
return $mimes;
}
WordPress可以识别并允许许多文件类型。如果需要更多,请按上述方式添加。自动将文件链接添加到内容。这很容易。钩入the_content
获取相关附件,将其吐出。
<?php
add_filter(\'the_content\', \'wpse66651_display_files\');
function wpse66651_display_files($c)
{
global $post;
if(!in_the_loop())
return $c;
$attachments = get_posts(array(
\'post_parent\' => $post->ID,
\'post_type\' => \'attachment\',
\'post_mime_type\' => \'application/xml\',
\'nopaging\' => true,
));
if(!$attachments)
return $c;
$list = \'<ul class="gpx-list">\';
foreach($attachments as $a)
$list .= \'<li>\' . wp_get_attachment_link($a->ID) . \'</li>\';
$list .= \'</ul>\';
return $c . $list;
}
a中的上述内容plugin.我与一家教会合作,该教会使用WordPress管理其网站和播客。到目前为止,他们每周有200个步骤来发布播客(我夸大了,但这是一个庞大的逐步列表)。除其他外,他们必须:录制布道,掌握布道录音,创建MP3,通过FileZilla将MP3上传到他们的服务器,但是如果可以的话,我想简化步骤4-6。我知道一些在线应用程序能够进行非常大的上传(GMail、Dropbox等)。每个布道都有70-80 MB,太大了,无法用简单的HTML上传表单处理。如果我最大限度地限制PHP文件大小,Flash上传程序是否能够管理这样
我想为我在博客上写的每一篇文章附上一个ZIP文件。
我想找到一个插件来完成这些事情:
1-Insert on the post editor 这样的一个盒子可以让我上传文件。
2-自动插入at the bottom of each post 一个允许读者下载我附加的文件的框。
我仍然会使用WordPress上传程序,但您需要修改它才能正常工作。假设您想要gpx文件(假设this 就是你的意思)。
当你上传东西时,WordPress会查看它的文件扩展名,并根据一组允许的mime类型,让上传通过或阻止它。这些允许的mime类型由函数获取get_allowed_mime_types
与WordPress中的几乎所有内容一样,它提供了一个过滤器来修改内容。upload_mimes
在这种情况下。
我们可以加入并允许.gpx
文件。Mime类型在的关联数组中指定regex_pattern => mime_type
总体安排
因此,要添加gpx:
<?php
add_filter(\'upload_mimes\', \'wpse66651_allow_gpx\');
/**
* Allow the uploading of .gpx files.
*
* @param array $mimes The allowed mime types in file extension => mime format
* @return array
*/
function wpse66651_allow_gpx($mimes)
{
$mimes[\'gpx\'] = \'application/xml\';
return $mimes;
}
WordPress可以识别并允许许多文件类型。如果需要更多,请按上述方式添加。自动将文件链接添加到内容。这很容易。钩入the_content
获取相关附件,将其吐出。
<?php
add_filter(\'the_content\', \'wpse66651_display_files\');
function wpse66651_display_files($c)
{
global $post;
if(!in_the_loop())
return $c;
$attachments = get_posts(array(
\'post_parent\' => $post->ID,
\'post_type\' => \'attachment\',
\'post_mime_type\' => \'application/xml\',
\'nopaging\' => true,
));
if(!$attachments)
return $c;
$list = \'<ul class="gpx-list">\';
foreach($attachments as $a)
$list .= \'<li>\' . wp_get_attachment_link($a->ID) . \'</li>\';
$list .= \'</ul>\';
return $c . $list;
}
a中的上述内容plugin.我的一个客户想把他的WordPress网站转移到我的服务器上。问题是他的网站没有在他的上传文件夹中使用子文件夹,而他上传文件夹的根目录中有超过1000000个文件。有没有一种方法可以将他的所有帖子上传到文件夹中,而不会丢失帖子中的附加链接和特色图片?