Home › Forum › Problemi Vari con WP › Recupero allegati di un post, problema con allegato usato in più post
-
AutorePost
-
-
16 Novembre 2010 alle 16:49 #15643rukbatPartecipante
Ciao a tutti, avrei una questione da sottoporre ai guru di WP…
Per recuperare gli allegati di un post uso la funzione
$args = array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => null,
'post_parent' => $post_id
);
$attachments = get_posts($args);
1) Ma se un media, ad esempio un'immagine, viene utilizzata in più post nel db l'attachment avrà come post_parent uno solo di questi articoli. Utilizzando la funzione qui sopra non verrà restituito l'attachment presente nel post...è possibile dato un post id recuperare anche questi allegati?
2) Se utilizzo le funzioni di editing delle immagini presenti in Media -> Modifica, come il crop/rotate/etc, vengono creati nuovi file rispetto all'originale. Ora, posto che inserisco lo stesso media in due post, prima e dopo la modifica, solo il primo post avrà l'attachment tramite la funzione sopra ma le "sizes" dell'allegato faranno riferimento alle modifiche quando invece il primo post ha l'immagine originale.
Spero di essere stato "chiarito", ma temo di no...
-
16 Novembre 2010 alle 16:55 #78626SteveAglAmministratore del forum
1) Nessun modo visto che in galleria c’è una imamgine in un solo e singolo post.. se la stesa imamgine si inserisce in più post l’unco sistema sarebbe cercare nei contenuti delgli articoli… estraendo tutte le imamgini con url compatibile raggruppando tutto etc etc… complicatissimo e pesantissimo.. gli attachemnte al momento per WP non possono essere di più padri… quindi se si usa una immagine in più posti occorre caricarla più volte con nomi diversi.
IN alternativa si potrebbe parsare il contenuto di un post quando lo si salva e se e negli upload s del blog e non una immagine magari estarna, creare campi personalizzati con lal’url di queste immagini e cercare quindi i campi personalizzati e non il fultext sul content.
2) Riletta tre volte e non ho capito nulla.. rispiega con un esempio con nomi e cognomi.
-
16 Novembre 2010 alle 17:02 #78629rukbatPartecipante
ok,
1) nuovo post e nuova immagine (post_id 1 e immagine originale)
2) ruoto l’immagine
3) nuovo post con stessa immagine (post_id 2 e immagine ruotata)
Solo il post_id 1 mi consente di recuperare l’allegato MA i postmeta dell’immagine sono ora relativi a quelli dell’immagine ruotata.
ps. Grazie per la rapida risposta!
-
16 Novembre 2010 alle 19:04 #78634SteveAglAmministratore del forum
Possiamo forse considerarlo un bug.. ma siccome una immagine si allega ad un solo post.. in pratica non lo è.. ergo la soluzione proposta in 1 è l’unica percorribile più volte la stesa imamgine con nomidiversi e passa la paura… metodo adottato da una grandissima catena di blog con 50 siti e decine di redattori esterni…
-
17 Novembre 2010 alle 8:09 #78657rukbatPartecipante
Bene, grazie per il consiglio.
Ciao.
-
-
AutorePost
- Devi essere connesso per rispondere a questo topic.