Support » Plugin: MimeTypes Link Icons » File size not being displayed in attachment.php

  • Resolved aluizioll

    (@aluizioll)


    The filesize for pages are ok, they are displayed. The problem arises when the attachment.php is loaded. There’s a if that checks is the attachment is an image and if it’s not it shows only the link for file as follows:
    <a href="<?php echo wp_get_attachment_url($post->ID) ?>" title="<?php echo esc_html(get_the_title($post->ID)) ?>" rel="attachment"><?php echo basename($post->guid);?></a>
    It happens that in this case the file size is not displayed. What could be wrong in this code?
    Thanks in advance.

    http://wordpress.org/extend/plugins/mimetypes-link-icons/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor jrf

    (@jrf)

    @aluizioll, could you check whether the new version (v3) fixes this ?. If so, please mark the topic resolved.
    If not, please add a link to a page where I can see the issue.

    Thanks, Juliette

    The problem is still there, even in v3. I can’t send you a link because the website is in a maintenance mode as it is not finished yet. But I could send you the source of the template although is mainly in Brazilian Portuguese. I translated a few comments and here it goes a part of it:

    <div class="entry-content">
                            <div class="entry-attachment">
                                <?php
                                /* If is a image, display it */
                                if (wp_attachment_is_image($post->id)) : $att_image = wp_get_attachment_image_src($post->id, "medium"); ?>
                                    <p class="attachment"><a href="<?php echo wp_get_attachment_url($post->id); ?>" title="<?php the_title(); ?>" rel="attachment"><img src="<?php echo $att_image[0]; ?>" width="<?php echo $att_image[1]; ?>" height="<?php echo $att_image[2]; ?>"  class="attachment-medium" alt="<?php $post->post_excerpt; ?>" /></a>
                                    </p>
                                <?php
                                /* If it's not a image, use MimeTypes Link Icons to show the file with its properties */
                                else :
                                    ?>
                                    <a href="<?php echo wp_get_attachment_url($post->ID) ?>" title="<?php echo esc_html(get_the_title($post->ID)) ?>" rel="attachment"><?php echo basename($post->guid);?></a>
    
                                    <?php endif; ?>
                            </div>
                            <div class="entry-caption">
                                <h3>Legenda da Mídia:</h3>
                                <?php
                                if (!empty($post->post_excerpt))
                                    the_excerpt();
                                else
                                    echo 'Sem legenda para esta mídia';
    
                                    ?>
                            </div>
                            <div class="entry-description">
                                <h3>Descrição da Mídia:</h3>
                                <?php
                                if(!empty($post->post_content))
                                    the_content('Continue Lendo <span class="meta-nav">»</span>');
                                else
                                    echo "Sem descrição para esta mídia";
                                ?>
                            </div>
                            <?php wp_link_pages('before=<div class="page-link">' . __('Pages:', 'seu-template') . '&after=</div>') ?>
    
                        </div><!-- .entry-content -->

    Plugin Contributor jrf

    (@jrf)

    @aluizioll, the plugin hooks into the_content and adds a filter to it. As you are not calling the_content for these links, the filter does not get applied and the icons and filesize will not show up.
    So the plugin works fine, it’s the template code which is a bit iffy…

    Anyway, the new plugin version adds a new function you can use in templates like this one to still get the MTLI plugin functionality.

    Replace this line:

    <a href="<?php echo wp_get_attachment_url($post->ID) ?>" title="<?php echo esc_html(get_the_title($post->ID)) ?>" rel="attachment"><?php echo basename($post->guid);?></a>

    with:

    echo mimetypes_to_icons( '<a href="'. wp_get_attachment_url($post->ID) . '" title="' .  esc_html(get_the_title($post->ID)) . '" rel="attachment">' .  basename($post->guid) . '</a>' );

    Hope this helps!

    Smile,
    Juliette

    It worked like a charm! Thank you a lot for your support.
    Cheers,
    Aluizio

    Plugin Contributor jrf

    (@jrf)

    You are welcome 😉 Glad to hear it worked.

    If you’re happy with the plugin, good ratings are always appreciated 😉

    Ok, I just gave it 5 stars =D

    Plugin Contributor jrf

    (@jrf)

    Thank you! 😉

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘File size not being displayed in attachment.php’ is closed to new replies.