Front end archive which displays links to full size images and pdfs?

[ad_1]

I’m building a site with Divi. I have about five hundred images and pdfs that I’d like to make available for viewing/download. Nothing fancy: I just want a page that displays a compact list of clickable titles with the date and category. When you click on a title, the full size image or pdf should display.

I thought I could use Divi’s “Blog” module to do this. I uploaded the files directly to an /uploads subfolder, and wrote a shell script with the following in the active loop:

//post creation
postid=$( wp post create –post_type=post –post_status=publish –porcelain –post_title=”$mytitle” –post_category=”mycategory” –post_date_gmt=”$mydate” )

#media import of the imagefile and attach it to the post as the featured image
wp media import “$myimg” –post_id=”$postid” –post_name=”$mytitle” –title=”$mytitle” –alt=”$mytitle” –featured_image

Unfortunately, although the script works, all of the images were blurry. So I did some research and tried many things, including editing my child theme’s function.php to stop cropping, set image quality to 100%, and to stop intermediate and big image size thresholds. I set the max sizes in Settings->Media to zero. (See comments for code I used.) The result of some of these changes was that I got a large (but not full size) image that was still blurry. When I deleted the intermediate sizes or prevented them from being made, the result was that no image showed at all!

Here are some possible approaches I’ve thought of:

* free plugin to show media (not a gallery though)
* Adapt my Divi child theme to force display of a full size image or simply a link to the media file if the post category is “mycategory”
* somehow tag the media I want as displayable, and create a new page template that lists links to all media with that tag

Any suggestions on how I could make this happen? Anything I do has to be easy to do in bulk (so I can’t go through all the files one by one and choose “Full” resolution, for instance). And it has to be very simple to upload new media and tag them as belonging to the archive display.

Thank you!

[ad_2]
1 Comment
  1. Changes I tried in functions.php:

    //set image quality to 100%
    add_filter(‘jpeg_quality’, function($arg){return 100;});
    add_filter(‘wp_editor_set_quality’, function($arg){return 100;});

    //add_filter( ‘intermediate_image_sizes’, ‘__return_empty_array’ );
    add_filter( ‘big_image_size_threshold’, ‘__return_false’ );

    //Remove Divi image cropping
    function wpc_remove_height_cropping($height) {
    return ‘9999’;
    }
    function wpc_remove_width_cropping($width) {
    return ‘9999’;
    }

    add_filter( ‘et_pb_blog_image_height’, ‘wpc_remove_height_cropping’ );
    add_filter( ‘et_pb_blog_image_width’, ‘wpc_remove_width_cropping’ );

    /**
    * @param array $sizes An associative array of image sizes.
    * @param array $metadata An associative array of image metadata: width, height, file.
    * Caution, these seem to prevent display of featured images in Divi
    */

    function remove_image_sizes( $sizes, $metadata ) {
    return [];
    }
    add_filter( ‘intermediate_image_sizes_advanced’, ‘remove_image_sizes’, 10, 2 );

    remove_image_size(‘large’);
    remove_image_size(‘medium’);
    remove_image_size(‘thumbnail’);

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer