zeitgrund blog

Plugin Link Uploaded Files (engl.) 0.2.1

Mittwoch, 12. September 2007 um 23:30 Uhr in Link Uploaded Files, Plugins

Download the latest release (0.2.1) of the plugin
Link Uploaded Files

For German Description click here / zur Deutschen Beschreibung

Description:
When writing a new post, WordPress provides the feature to upload files and embed them to the post. But you have to embed every file separately.
And you don’t have special functions, like giving the file links or images a certain class (for CSS styling).
Or perhaps you use the the_excerpt(); function which has the attribute not to show pictures or links.
Another need might be the possibility to link the uploaded files without showing the post (maybe for a special archive e.g.).

To solve these problems you can use this plugin.
The plugin call can be put anywhere inside the loop.
And if there were uploaded items in the post, the plugin will link or respectively show them, even if they are not embedded to the post.
Just upload the files – that’s all.

Summary of functions:

  • The plugin links to all files who are uploaded by a post – you dont’ have to embed them to the post
  • Images can be linked or shown directly
  • File description is used as link text. If there is no description, the title (filename if not set) will be used
  • Links and images have the class=”attachment” – the class can be changed by parameter
  • You can prevent files from being listed by writing (to minus) anywhere in the file description
  • Special text or code can be used before and after every link item

Download:
link-uploaded-files.zip (2kb)

Changelog:
0.2.1: Added compatiblity for WordPress 2.3.

Use:
Download ZIP and unzip. Upload link-uploaded-files.php to your /wp-content/plugins/ directory.
Go to admin backend and activate the plugin.

Put the following code into the template files of your theme, just where you want to show the file links:

<?php zg_uploaded_files(); ?>

Remember, that the code must be inside the loop.

Parameters:

show_images= (Boolean)
TRUE (default) – images are shown, not linked
FALSE – images are linked

link_class= (String)
Class (class=’ ‘) of the link or image, for styling with CSS. Default isattachment.

before= (String)
Code (HTML) that is used in front of every link. There is no default.

after= (String)
Code (HTML) that is used after every link. Default is <br />.

Code examples:

<?php zg_uploaded_files('show_images=FALSE&link_class=attach-link&before=<strong>Download: </strong>'); ?>

<ul><?php zg_uploaded_files('before=<li>&after=</li>&show_images=FALSE'); ?></ul>



12 Kommentare zu ' Plugin Link Uploaded Files (engl.) 0.2.1 '

Kommentar schreiben

  1. Simon schrieb:

    gutes plugin, genau soetwas suche ich, jedoch fehlt mir noch eine funktion: ist es möglich auch nur eines der hochgeladenen bilder auszugeben (das erste). ich möchte auf meiner blogseite ein vorschaubild einbetten und dann auf der post-seite alle bilder anzeigen.

    9. Februar 2009 um 12:51

  2. Olaf schrieb:

    Hallo Simon,

    öffne die Plugindatei…da findest du folgenden Code
    $zg_customfields = $wpdb->get_results("SELECT guid, post_mime_type, post_content, post_title
    FROM $wpdb->posts
    WHERE post_type = 'attachment' && post_parent = $id
    ORDER BY ID ASC");

    Ändere diesen wie folgt um:

    $zg_customfields = $wpdb->get_results("SELECT guid, post_mime_type, post_content, post_title
    FROM $wpdb->posts
    WHERE post_type = 'attachment' && post_parent = $id LIMIT 1
    ORDER BY ID ASC");

    Evtl. muss am Ende noch ASC in DESC geändert werden, damit das erste hochgeladene Bild benutzt wird.

    9. Februar 2009 um 14:34

  3. Simon schrieb:

    Danke für die Hilfe, bei mir funktioniert es in Orginalform und mehreren Bildern, jedoch nicht die Änderung mit LIMIT 1.
    Ist es zudem möglich die verschiedenen Größen (thumb, …) auszulesen? Ansonsten müsste ich die Bilder im Vorraus von Hand verkleinern.

    9. Februar 2009 um 15:33

  4. Olaf schrieb:

    Tut mir leid, mein Fehler.
    Das LIMIT 1
    muss ganz an das Ende, hinter ORDER BY ID ASC.
    Also so:
    ORDER BY ID ASC LIMIT 1″);

    das mit den verschiedenen Größen ist leider nicht berücksichtigt.

    9. Februar 2009 um 16:03

  5. Simon schrieb:

    Vielen Dank! funktioniert einwandfrei, jetzt muss ich nur noch versuchen im Artikel mehrere Bilder auf gleiche Weise zu platzieren…

    9. Februar 2009 um 16:27

  6. David schrieb:

    Hallo Olaf,

    super Plugin, genau das, was ich brauche… ist es möglich, links für die hochgeladenen bilder selbst zu definieren?

    1. Juni 2009 um 8:08

  7. Olaf schrieb:

    @David:
    Was meinst du damit konkret?

    1. Juni 2009 um 12:06

  8. David schrieb:

    also, dass man per klick auf das Bild ein anderes, zb. via shadowbox etc., ansehen kann, bzw. dass man auf eine weitere seite gelangt usw.

    die frage ist, ob man das direkt für jeden neuen posteintrag angeben kann…

    ich hoffe du kannst nachvollziehen…

    1. Juni 2009 um 12:23

  9. Olaf schrieb:

    Nun ich weiß leider nicht, welche Vorraussetzungen dafür gegeben sein müssen, deshalb kann ich auch nichts näheres dazu sagen.
    Falls es nicht reicht einfach nur die Klasse anzugeben (siehe Beschreibung), dann kannst du das Plugin notfalls auch selber ändern. In Zeile 101 werden die Links für Bilder erzeugt. Ändere diese Zeile in folgenen Code:

    echo "<a href=\"$zg_cf_out->guid\" title=\"$zg_cf_out->post_title\" class=\"$link_class\"><img src=\"$zg_cf_out->guid\" alt=\"$zg_cf_out->post_title\" title=\"$zg_cf_out->post_content\" class=\"$link_class\" /></a>$after <br /> \n";

    Du kannst dort auch eigene Attribute eintragen, z.B. rel=\”lightbox\” oder ähnliches.

    1. Juni 2009 um 12:57

  10. David schrieb:

    ich habe eine lösung gefunden, vielen dank! eine frage habe ich allerdings noch: hast du das plugin schon mal auf opera getestet? bei meinem blog springen die bilder teilweise nach rechts auf opera, hast du eine ahnung, woran das liegen könnte? – http://dkmotion.com/

    2. Juni 2009 um 8:44

  11. Olaf schrieb:

    Mein Plugin formatiert die Ausgabe der Bilder ja nicht, es ist also eine CSS-Sache des Themes.
    Aber evtl. stört der HTML-Zeilenumbruch der vom Plugin ausgegeben wird.

    2. Juni 2009 um 11:31

  12. David schrieb:

    ich habs jetzt mit dem css einigermaßen hingebastelt… vielen dank

    2. Juni 2009 um 12:03

Kommentar verfassen

Zeilen und Absätze brechen automatisch um, E-Mail Adresse wird nicht veröffentlicht (ist aber obligatorisch), HTML erlaubt: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>