Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

media cat/tag / single view and grid view #211

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions theme/attachment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<div class="container">
<?php get_template_part('templates/page', 'header'); ?>
<div class="entry">
<div class="entry-inner">


<p class='resolutions'> Downloads:
<?php
$images = array();
$image_sizes = get_intermediate_image_sizes();
array_unshift( $image_sizes, 'full' );

$c = '';
foreach( $image_sizes as $image_size ) {

$image = wp_get_attachment_image_src( get_the_ID(), $image_size );
$name = $image_size . ' (' . $image[1] . 'x' . $image[2] . ')';
$images[] = '<a href="' . $image[0] . '">' . $name . '</a>';

if($image_size == 'thumbnail'){
$c = $image[0];

}
}
echo '<img src="'.$c.'" />';
echo implode( ' | ', $images );



?>

</p>
<?php get_template_part('templates/entry-taxonomies'); ?>

</div>
<div class="clear"></div>
</div><!--/.entry-->
</div>
8 changes: 8 additions & 0 deletions theme/lib/nuitdebout/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,11 @@ function getAttachmentThumb($id) {
$url = wp_get_attachment_image_src($thumb , [330, 180])[0];
return $url;
}
function attachment_search( $query ) {
if ( $query->is_search ) {
$query->set( 'post_type', array( 'post', 'attachment' ) );
$query->set( 'post_status', array( 'publish', 'inherit' ) );
}
return $query;
}
add_filter( 'pre_get_posts', 'attachment_search' );
22 changes: 22 additions & 0 deletions theme/mediasquery.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* Template Name: page media query
* @package WordPress
* @subpackage Twenty_Fourteen
* @since Twenty Fourteen 1.0
*/
$args = array(
'post_type' => 'attachment',
'post_status' => 'any'
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
get_template_part('templates/entry-taxonomies');
echo wp_get_attachment_image( get_the_ID(), 'thumbnail' );
}
} else {
// no attachments found
}
wp_reset_postdata();
23 changes: 23 additions & 0 deletions theme/taxonomy-media_category.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<div class="container">
<?php get_template_part('templates/page', 'header'); ?>


<?php while (have_posts()) : the_post(); ?>
<article <?php post_class(); ?>>
<header>
<?php
$attachment_id = get_post_thumbnail_id();
$attachment_page = get_attachment_link( $attachment_id );
?>
<a href="<?php echo $attachment_page; ?>"><?php the_title() ?></a>
</header>
<div class="entry-summary">
<?php the_content(); ?>
<?php get_template_part('templates/entry-taxonomies'); ?>
</div>
</article>
<hr/>
<?php endwhile; ?>

<?php the_posts_navigation(); ?>
</div>
23 changes: 23 additions & 0 deletions theme/taxonomy-media_tag.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<div class="container">
<?php get_template_part('templates/page', 'header'); ?>


<?php while (have_posts()) : the_post(); ?>
<article <?php post_class(); ?>>
<header>
<?php
$attachment_id = get_post_thumbnail_id();
$attachment_page = get_attachment_link( $attachment_id );
?>
<a href="<?php echo $attachment_page; ?>"><?php the_title() ?></a>
</header>
<div class="entry-summary">
<?php the_content(); ?>
<?php get_template_part('templates/entry-taxonomies'); ?>
</div>
</article>
<hr/>
<?php endwhile; ?>

<?php the_posts_navigation(); ?>
</div>
7 changes: 6 additions & 1 deletion theme/templates/content-search.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<article <?php post_class(); ?>>
<header>
<?php if (get_post_type() === 'attachment') {
echo 'Media:';
}
?>

<h2 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php if (get_post_type() === 'post') { get_template_part('templates/entry-meta'); } ?>
</header>
<div class="entry-summary">
<?php the_excerpt(); ?>
<?php //the_excerpt(); ?>
</div>
</article>
8 changes: 4 additions & 4 deletions theme/templates/entry-taxonomies.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
$taxonomies = [];
$types = array('category', 'post_tag','media_category');
$types = array('category','media_category', 'post_tag','media_tag');
foreach( $types as $tax ) {
$categories = get_the_terms( $post->ID, $tax );
if($categories){
Expand All @@ -13,17 +13,17 @@
<div class="post-taxonomies">
<?php foreach( $taxonomies as $tax => $categories ) : ?>
<span class="post-taxonomy post-taxonomy--<?php echo $tax ?>">
<?php if($tax == 'category'): ?>
<?php if($tax == 'category' || $tax == 'media_category'): ?>
<span>Classé dans </span>
<?php endif; ?>
<?php if($tax == 'post_tag'): ?>
<?php if($tax == 'post_tag' || $tax == 'media_tag'): ?>
<span> | </span>
<?php endif; ?>
<?php foreach( $categories as $category ) : ?>
<a href="<?php echo esc_url( get_category_link( $category->term_id ) )?>">
<?php echo esc_html( $category->name ) ?>
</a>
<?php if($tax =='category' && $category !== end($categories)) : ?>,<?php endif; ?>
<?php if(($tax =='category' || $tax =='media_category') && $category !== end($categories)) : ?>,<?php endif; ?>
<?php endforeach ?>
</span>
<?php endforeach; ?>
Expand Down